JavaScript Simplified / Chapter 23 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 code, the first number is the index of the _______ point. continents.splice(3, 4, "Australia"); insertion insertion
In the following code, the second number is the number of _______ to remove. continents.splice(3, 4, "Australia"); elements elements
Code a statement that removes the second element from an array named pets. Don't insert any additional elements. pets.splice(1, 1); pets\.splice\(1,1\);
The array is nums. Code a statement that inserts the integer 89 at index 5 without removing any elements. nums.splice(5, 0, 89); nums\.splice\(5,0,89\);
Remove the first two elements and insert "Kia". Make up the array name. cars.splice(0, 2, "Kia"); [a-z_$][a-zA-Z0-9_$]*\.splice\(0,2,•Kia•\);
Insert an integer after the second element. Don't remove any elements. Make up the array name and the integer. nums.splice(2, 0, 24); [a-z_$][a-zA-Z0-9_$]*\.splice\(2,0,(0|-?[1-9][\d]*)\);
Alter the following array, named nums, so it becomes [-1,0,1,3,4]. [-1,0,1,2] nums.splice(3, 1, 3, 4); nums\.splice\(3,1,3,4\);
Alter the following array, named players so it becomes ["Ji", "Toledo"]. ["Fox","Abe","Ko","Rock","Klaus"] players.splice(0, 5, "Ji", "Toledo"); players\.splice\(0,5,•Ji•,•Toledo•\);
  1. Create a four-element array.
  2. Using splice(), replace the second element with a new element.
  3. Display the altered array in an alert.
  4. Click the Result button (or, after revising, don't click, just wait).
  5. Wait a moment.
  6. If you've coded correctly, an alert will display the altered array.
  7. Dismiss the alert by clicking OK.
  8. For help with this code, see Chapter 23 in the book.
  1. Create a three-element array of integers.
  2. Assign a fourth integer to a variable.
  3. Using splice(), replace the last element of the array using the variable.
  4. Display the altered array in an alert.
  5. Click the Result button (or, after revising, don't click, just wait).
  6. Wait a moment.
  7. If you've coded correctly, an alert will display the altered array.
  8. Dismiss the alert by clicking OK.
  9. For help with this code, see Chapter 23 in the book.