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

A collection of values that never contains duplicates is a ____. set set
A collection of values that can contain duplicates is an ______. array array
Fill in the blank to create the set {1, 2, 3}. const smallNumbers = new Set___________; ([1, 2, 3]) \(\[1,2,3\]\)
Fill in the blank to create a new set containing the integers 0 and 1. const smallNumbers = ___________; new Set([0, 1]) newSet\(\[0,1\]\)
Create an empty set named popArtists. const popArtists = new Set(); constpopArtists=newSet\(\);
Create a set containing two strings. Make up the names of the set and the strings. const flavors = new Set(["chocolate", "vanilla"]); const[a-z_$][a-zA-Z0-9_$]*=newSet\(\[•.*•,•.*•\]\);
Add an integer to a set. Make up the name of the set and the integer. scores.add(12); [a-z_$][a-zA-Z0-9_$]*\.add\((0|-?[1-9][\d]*)\);
Add two integers to a set in a chain. Make up the names of the set and the integers. someNums.add(1).add(2); [a-z_$][a-zA-Z0-9_$]*\.add\((0|-?[1-9][\d]*)\)\.add\((0|-?[1-9][\d]*)\);
  1. Below my code create a set named nations. The set contains three strings.
  2. Click the Click to see first item button to see the first string in the Result panel.
  3. If you've coded correctly, you'll see the first string in the set in the Result panel.
  4. For help with this code, see Chapter 97 in the book.
  1. Below my code create a set of three integers.
  2. In a separate statement, add two more integers using a chain.
  3. Click the Click to see last item button to see the last integer in the Result panel.
  4. If you've coded correctly, the you'll see the last integer in the set in the Result panel.
  5. Dismiss the alert by clicking OK.
  6. For help with this code, see Chapter 97 in the book.