I am learning javascript where I get this error when I convert a object of js into a string it says semicolon required
2
You might want to check a tutorial for the basic syntax.
There you are settings everything between ' that can only be used for one line strings. That is probably not what you are trying to do.
'
If you really want a multiline string, you can use the backticks. Or you can have a normal object and use JSON.stringify to turn it into a string.
JSON.stringify
When using single or double quotes, you can only do strings on one line, 2 possible solutions is using JSON.Stringify or backticks. Using backticks allows multiline strings and JSON.Stringify will convert everything to a string too!
JSON.Stringify
Click here to cancel reply.
2
Answers
You might want to check a tutorial for the basic syntax.
There you are settings everything between
'
that can only be used for one line strings. That is probably not what you are trying to do.If you really want a multiline string, you can use the backticks. Or you can have a normal object and use
JSON.stringify
to turn it into a string.When using single or double quotes, you can only do strings on one line, 2 possible solutions is using
JSON.Stringify
or backticks. Using backticks allows multiline strings and JSON.Stringify will convert everything to a string too!