Question:
I am trying to put lines of text into an array:
messageArray = new Array();messageArray[0] = 'Information deduced from the document's content.'
Iām running into problems with the single quotes (ā) because it thinks that the text is over and that there is an extra ā. What can I do about this?
Answer:
Luckily there is a simple solution to the problem youāve run into. You can either use double quotes (ā) or single quotes (ā) to delimit your JavaScript strings. So if your string is likely to include one kind of quote within it, just use the other kind to actually tell the browser where the string starts and ends. For example:
messageArray[0] = "Information deduced from the document's content.";
You can also escape the quotes within your strings by putting a backslash before them. Like this:
ā Single quotation mark
ā Double quotation mark