-2

My ambition is to encode my programmcode with window.btoa(), but how can i write an string with programmcode in it - the problem is that the comipiler thinks the string is ended after the first " in the code.

example:

var engine = '';


function all_this_in_the_string() {
  var examples_string = 'single';
  var double_ = "double";
}

// I have about 600 lines code with single and double quotes...of course the code is in more than one line.
// Is there a way to get this code into the string (engine) that i can encode with the line above ?

console.log(window.btoa(engine));

greets, david

1 Answers1

0

You'll need to vary between single and double quotes.

var engine = 'function() { var examples_string = "here_is_the_problem"}';
Alex R
  • 624
  • 3
  • 10
  • You can also escape the quotes `'function() { var examples_string = \'here_is_the_problem\'}'` – jcubic Mar 12 '16 at 15:22