wp_enqueue_scripts with JS script as a string

Unfortunately, wp_enqueue_script doesn’t work that way — the second parameter is for a URL as per the documentation.

But you could use wp_add_inline_script() (if there’s an enqueue’d script to attach it to) or, as in olden times, just hook in to wp_head or wp_footer.