Example alert she said i am happy question

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: .. Can be enclosed in matching pairs of single or double quotes. Examples: alert('programming is fun'); alert("programming is fun"); To include a single quote in a string, enclose it with double quotes. Example: alert( "You're very nice" ); To include a double quote in a string, enclose it with single quotes. Example: alert ( 'She said: "I am Happy". ' ); Question: how to display this string: She said: "I don't understand!" (CS1301) Introduction to Computer Programming City Univ of HK / Dept of CS / Helena Wong http://www.cs.cityu.edu.hk/~helena 4. Program Structure III - 16 Data Types Strings Question: how to display this string: She said: "I don't understand!" An a p p ro a c h : alert( 'She said: "I don' + "'" + 't understand!" ' ); Exp la na tio n : ` She said: "I don ' "'" ` t understand!" ' : a double quote in ' ... ' (a pair of single quotes). : a single quote in " ... " (a pair of double quotes). : a double quote in ' ... ' (a pair of single q...
View Full Document

Ask a homework question - tutors are online