var num = "2" + "2";
What is the value of num? Include quotation marks.
Sorry, that's incorrect. The correct answer:
"22"
It's a concatenation of two strings, not the addition of two numbers.
What is it called when you combine two or more strings, using the plus sign?
Sorry, that's incorrect. The correct answer:
concatenation
message = ("Hello," + "Dolly");
What is the value of message? (Include the quotation marks.)
Sorry, that's incorrect. The correct answer:
"Hello,Dolly"
There's no space at the end of "Hello," or at the beginning of "Dolly," a common coding error.
alert("33" + 3);
What message displays in the alert box?
Sorry, that's incorrect. The correct answer:
333
When code mixes strings and numbers, numbers are converted to strings.
Drag-and-drop. Holding down the left mouse button, drag the pieces to create a statement that assigns to saying the concatenation of the two strings.
Click in the box and type the next character. I'll autocomplete. Don't type spaces.
Write a statement that assigns to scribe the concatenation of the first and last names of England's greatest playwright. The variable hasn't been declared beforehand.
The correct code is:
var scribe = "William " + "Shakespeare";
Fail-safe coding. If you type the wrong character, I'll cancel the keystroke. Type spaces.
Write an alert that displays the concatenation of the two parts of "Woo hoo"
The correct code:
alert("Woo " + "hoo");
Don't forget the space that comes after "Woo"
Write a statement that assigns to a variable the concatenation of the two parts of "Oh yeah" (no period at the end). The second part is "yeah" The variable hasn't been declared beforehand.
Sorry, that's incorrect. An example:
var expression = "Oh " + "yeah";
Write a statement that concatenates two variables and assigns the result to a third variable. The third variable hasn't been declared beforehand.
Sorry, that's incorrect. The correct code:
var combo = firstPart + secondPart;
Write a statement that displays an alert. The message is a string concatenated with a variable.
Sorry, that's incorrect. An example:
alert("Hi, " + userName);
Write a statement that assigns to a variable the concatenation of a string with a number. The variable has been declared beforehand.
Sorry, that's incorrect. An example:
cost = "The cost: " + 59.80;
Assign strings to two variables. Then concatenate them and assign the result to a third variable. None of the variables have been declared beforehand.
Sorry, that's incorrect. An example:
var firstPart = "Hello, ";
var secondPart = "Dolly!";
var show = firstPart + secondPart;
Time goal: 20 seconds. (The timer starts when you click in the answer field.)
message = ("Hello," + "Dolly");
What is the value of message? (Include the quotation marks.)
Sorry, that's incorrect. The correct answer:
"Hello,Dolly"
There's no space at the end of "Hello," or at the beginning of "Dolly," a common coding error.
Time goal: 30 seconds. Write a statement that concatenates two variables and assigns the result to a third variable. The third variable hasn't been declared beforehand.
Sorry, that's incorrect. The correct code:
var combo = firstPart + secondPart;
Time goal: 35 seconds. Write a statement that displays an alert. The message is a string concatenated with a variable.
Sorry, that's incorrect. An example:
alert("Hi, " + userName);
Time goal: 35 seconds. Write a statement that assigns to a variable the concatenation of a string and a number. The variable has been declared beforehand.
Sorry, that's incorrect. An example:
cost = "The cost: " + 59.80;
Time goal: 40 seconds. Write a statement that assigns to scribe the concatenation of the first and last names of England's greatest playwright (including the space between them). The variable hasn't been declared beforehand.
Sorry, that's incorrect. The correct code:
var scribe = "William " + "Shakespeare";
Time goal: 60 seconds. Assign strings to two variables. Then concatenate them and assign the result to a third variable. None of the variables have been declared beforehand.
Sorry, that's incorrect. An example:
var firstPart = "Hello, ";
var secondPart = "Dolly!";
var show = firstPart + secondPart;
Live coding exercise:
Type out the code. If you copy and paste it from the screen showing the correct code, it may not work.
Live coding exercise:
Type out the code. If you copy and paste it from the screen showing the correct code, it may not work.
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to jsFiddle. See my brief demo of jsFiddle.
Post a review on Amazon for the paperback or the Kindle edition.
Email me to give me a compliment, complaint, or correction. I'll respond.
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19