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

Any data type can be used as a key in ____. maps maps
Assign a value to a map's key. The key is a string. The value is an integer. Make up everything. iron.set("atomic number", 26); [a-z_$][a-zA-Z0-9_$]*\.set\(•.*•,(0|-?[1-9][\d]*)\);
Fill in the blank to assign the key and value to the map. pakistanMap.___("population", 221000000); set set
Fill in the blank to assign the value to the variable. let pakPop = pakistanMap.___"population"); get get
Get a count of the key-value pairs in a map and assign it to a variable that hasn't been declared beforehand. Make up everything. let count = species.size; let[a-z_$][a-zA-Z0-9_$]*=[a-z_$][a-zA-Z0-9_$]*\.size;
Remove a key-value pair from a map. The key is a string. Make up everything. species.delete("range"); [a-z_$][a-zA-Z0-9_$]*\.delete\(•.*•\);
Remove all the key-value pairs from a map. Make up the name of the map. species.clear(); [a-z_$][a-zA-Z0-9_$]*\.clear\(\);
Check whether a map contains a particular key-value pair and assign the result to a variable that hasn't been declared beforehand. The key is an integer. Make up everything. let itsThere = species.has(12); let[a-z_$][a-zA-Z0-9_$]*=[a-z_$][a-zA-Z0-9_$]*\.has\((0|-?[1-9][\d]*)\);
  1. I've created an empty map. Check whether the map has a particular key-value pair. If not, add the key-value pair.
  2. Display the value of the new element in an alert.
  3. Click the Result button
  4. If you've coded correctly, an alert will display the value.
  5. Dismiss the alert by clicking OK.
  6. For help with this code, see Chapter 102 in the book.
  1. Instantiate a map with two key-value pairs.
  2. Assign one of the values to a variable.
  3. Display the value of the variable in an alert.
  4. Click the Result button
  5. If you've coded correctly, an alert will display the value.
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 102 in the book.