Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unterminated string literal

Tags:

javascript

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?

like image 626
VIKASH Avatar asked Mar 14 '11 08:03

VIKASH


People also ask

How do you fix unterminated strings?

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.

Which is the string literal?

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.


1 Answers

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...

like image 51
Gabriel Hurley Avatar answered Oct 06 '22 00:10

Gabriel Hurley