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

If the value of pets is ["dog","cat","fly","bug","ox"] and you write the following statement, the value of sliceOfPets is [______]. const sliceOfPets = pets.slice(3, 4); "bug" •bug•
If the value of pets is ["dog","cat","fly","bug","ox"] and you write the following statement, the value of sliceOfPets is [______]. const sliceOfPets = pets.slice(3); "bug","ox" •bug•,•ox•
The value of pets is ["dog","cat","fly","bug","ox"]. Code a slice statement that assigns "dog" and "cat" to a new array, sliceOfPets. const sliceOfPets = pets.slice(0, 2); constsliceOfPets=pets\.slice\(0,2\);
The value of pets is ["dog","cat","fly","bug","ox"]. Code a concise slice statement that assigns "fly" "bug", and "ox" to a new array, oddPets. const oddPets = pets.slice(2); constoddPets=pets\.slice\(2\);
The value of the array series is [4,6,8,10]. Code a slice statement that assigns the first element to a new array, x. const x = series.slice(0, 1); constx=series\.slice\(0,1\);
The value of the array switches is [true,true,false,true,true,false]. Code a slice statement that assigns the two middle elements to a new array, bools. const bools = switches.slice(2, 4); constbools=switches\.slice\(2,4\);
The value of the array minerals is ["carbon","iron","tungsten"]. Code a concise slice statement that assigns the last element to a new array, t. const t = minerals.slice(2); constt=minerals\.slice\(2\);
The array minerals has been declared with the let keyword. The array's value is ["carbon","iron","tungsten"]. Code a slice statement that reduces the array to the first two elements. minerals = minerals.slice(0, 2); minerals=minerals\.slice\(0,2\);
  1. I've coded an array. Leave my code intact. Below my code, write a slice statement that assigns the first three elements to a new array.
  2. Display the new 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 new array.
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 24 in the book.
  1. I've coded an array using the let keyword. Leave my code intact. Below my code, write a slice statement that reduces the array to the first two elements.
  2. Display the altered 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 altered array.
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 24 in the book.