Concatenating text strings Flashcards
var num = "2" + "2"; What is the value of num? Include quotation marks.
“22”
What is it called when you combine two or more strings, using the plus sign?
concatenation
message = (“Hello,” + “Dolly”);
What is the value of message? (Include the quotation marks.)
“Hello,Dolly”
alert(“33” + 3);
What message displays in the alert box?
333
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.
var scribe = “William “ + “Shakespeare”;
Write an alert that displays the concatenation of the two parts of “Woo hoo”
alert(“Woo “ + “hoo”);
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.
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.
var combo = firstPart + secondPart;
Write a statement that displays an alert. The message is a string concatenated with a variable.
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.
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.
var firstPart = "Hello, "; var secondPart = "Dolly!"; var show = firstPart + secondPart;