JavaScript Simplified / Chapter 8 Exercises

  • Index of exercises
  • Email me

1

2

3

4

5

6

7

8

9

10

Congratulations. You've aced all the exercises for this chapter.


To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to CodePen.


Are you ready to rate JavaScript Simplified? on Amazon?


Rate it on Amazon.

0,1,2,3,4,5,6,7,8,9

0

0

0

0

In the following statement, what is the value of num? Include quotation marks. let num = "2" + "2"; "22" •?22•?
What is it called when you combine two or more strings, using the plus sign? concatenation concatenation
In the following statement, what is the value of message? (Include the quotation marks.) message = ("Hello," + "Dolly"); "Hello,Dolly" •?Hello,Dolly•?
When the following statement executes, what message displays in the alert box? alert("33" + 3); 333 333
Write a statement that assigns to the variable famousCat the concatenation of the first name (Grumpy) and last name (Cat) of the internet's famous grouchy feline. The variable hasn't been declared beforehand. let famousCat = "Grumpy " + "Cat"; letfamousCat=•Grumpy•\+•Cat•;
Write an alert that displays the concatenation of your first name and your last name. Make up the names if you prefer. alert("Mark " + "Myers"); alert\(•.*•\+•.*•\);
Write a statement that concatenates two variables and assigns the result to a third variable. The third variable hasn't been declared beforehand. Make up the variable names. let combo = firstPart + secondPart; let[a-z_$][a-zA-Z0-9_$]*=[a-z_$][a-zA-Z0-9_$]*\+[a-z_$][a-zA-Z0-9_$]*;
Assign strings to two variables. Then concatenate them and assign the result to a third variable. None of the variables have been declared beforehand. Make up the variable names and strings. let firstPart = "Hello, ";
let secondPart = "Dolly!";
let show = firstPart + secondPart;
let([a-z_$][a-zA-Z0-9_$]*)=•.*•;[\r\n]let([a-z_$][a-zA-Z0-9_$]*)=•.*•;[\r\n]let[a-z_$][a-zA-Z0-9_$]*=\1\+\2;
  1. Assign a string to a variable.
  2. Display an alert, specifying as the message the concatenation of the variable plus a string.
  3. Click the Result button (or, after revising, don't click, just wait).
  4. Wait a moment.
  5. If you've coded correctly, the message will display in an alert.
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 8 in the book.
  1. Assign two strings to two variables.
  2. Assign to a third variable the concatenation of the first two variables.
  3. Display an alert, specifying the third variable as the message.
  4. Click the Result button (or, after revising, don't click, just wait).
  5. Wait a moment.
  6. If you've coded correctly, the messge will display in an alert.
  7. Dismiss the alert by clicking OK.
  8. For help with this code, see Chapter 8 in the book.