The following code:
var str= "<strong>English Comprehension<\/strong> <br\/> <ul> <li> Synonyms/Antonyms/Word Meaning (Vocabulary)<\/li> <li> Complete the Sentence (Grammar)<\/li> <li> Spot error/Correct sentence (Grammar/sentence construction)<\/li> <li> Sentence Ordering (Comprehension skills)<\/li> <li> Questions based on passage (Comprehension skills)<\/li> <\/ul> <br\/>";
Gives the error: "unterminated string literal". Whats the problem?
To solve the "Unterminated string constant" error, make sure to enclose your strings in quotes consistently. String literals must be enclosed in single quotes, double quotes or backticks. When writing a multiline string use backticks.
A string literal contains a sequence of characters or escape sequences enclosed in double quotation mark symbols. A string literal with the prefix L is a wide string literal. A string literal without the prefix L is an ordinary or narrow string literal.
You can't split a string across lines like that in javascript. You could accomplish the same readability by making each line a separate string and concatenating them with the plus sign like so:
var str = "<strong>English Comprehension</strong>" + "<br />" + "<ul>" + "<li>Synonyms/Antonyms/Word Meaning (Vocabulary)</li>"
and so on...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With