Concatenating text strings Flashcards

1
Q
var num = "2" + "2";
What is the value of num? Include quotation marks.
A

“22”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is it called when you combine two or more strings, using the plus sign?

A

concatenation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

message = (“Hello,” + “Dolly”);

What is the value of message? (Include the quotation marks.)

A

“Hello,Dolly”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

alert(“33” + 3);

What message displays in the alert box?

A

333

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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.

A

var scribe = “William “ + “Shakespeare”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Write an alert that displays the concatenation of the two parts of “Woo hoo”

A

alert(“Woo “ + “hoo”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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.

A

var expression = “Oh “ + “yeah”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Write a statement that concatenates two variables and assigns the result to a third variable. The third variable hasn’t been declared beforehand.

A

var combo = firstPart + secondPart;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Write a statement that displays an alert. The message is a string concatenated with a variable.

A

alert(“Hi, “ + userName);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Write a statement that assigns to a variable the concatenation of a string with a number. The variable has been declared beforehand.

A

cost = “The cost: “ + 59.80;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Assign strings to two variables. Then concatenate them and assign the result to a third variable. None of the variables have been declared beforehand.

A
var firstPart = "Hello, ";
var secondPart = "Dolly!";
var show = firstPart + secondPart;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly