JavaScript Simplified / Chapter 22 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

What is the keyword that removes the last element of an array? pop pop
What is the keyword that adds one or more elements to the end of an array? push push
What is the keyword that removes the first element of an array? shift shift
What is the keyword that adds one or more elements to the beginning of an array. unshift unshift
Remove the last element from the array x. x.pop(); x\.pop\(\);
Add the integer 1 to the end of the array x. x.push(1); x\.push\(1\);
Remove the first element from the array x. x.shift(); x\.shift\(\);
Add two elements, the integers 1 and 2, to the beginning of the array x. x.unshift(1, 2); x\.unshift\(1,2\);
  1. I've coded an array. Leave it intact. Add two elements to the end of the array.
  2. Display the array in an alert.
  3. Click the Result button (or, after revising, don't click, just wait).
  4. Wait a moment.
  5. If you've coded correctly, an alert will display the array.
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 22 in the book.
  1. I've coded an array. Leave it intact. Remove the first element, assigning it to a variable.
  2. Display the removed element in an alert.
  3. Click the Result button (or, after revising, don't click, just wait).
  4. Wait a moment.
  5. If you've coded correctly, an alert will display the removed element.
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 22 in the book.