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

To create a set, you use JavaScript's built-in ______. constructor constructor
Create an empty set named cities. const cities = new Set(); constcities=newSet\(\);
An array has been assigned to the variable arr. Use it to create a set named plants. const plants = new Set(arr); constplants=newSet\(arr\);
Count the number of values in a set named products and assign the number to the variable num that hasn't been declared beforehand. let num = products.size; letnum=products\.size;
Remove the integer 0 from the set named numbers. numbers.delete(0); numbers\.delete\(0\);
Remove all the values from a set named numbers. numbers.clear(); numbers\.clear\(\);
Check whether a set includes a particular string and assign the result to a variable that hasn't been declared beforehand. Make up everything. let hasString = mammals.has("slow loris"); let[a-z_$][a-zA-Z0-9_$]*=[a-z_$][a-zA-Z0-9_$]*\.has\(•.*•\);
If a set contains more than three values, display an alert that confirms it. Make up everything. if (mammals.size > 3) {
  alert("More values than 3");
}
if\([a-z_$][a-zA-Z0-9_$]*\.size>3\){[\r\n]alert\(•.*•\);[\r\n]}
  1. I've created a set. If the set contains "loris", remove it.
  2. Display the size of the set in an alert.
  3. Click the Result button (or, after revising, don't click, just wait).
  4. If you've coded correctly, an alert will display the number 4.
  5. Dismiss the alert by clicking OK.
  6. For help with this code, see Chapter 98 in the book.
  1. I've created a set. Remove all the values.
  2. Add a value.
  3. Display the size of the set in an alert.
  4. Click the Result button (or, after revising, don't click, just wait).
  5. If you've coded correctly, an alert will display the number 1.
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 98 in the book.