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


0,1,2,3,4,5,6,7,8,9

0

0

0

0

A map is a collection of ___-value pairs. key key
You create a map by using a built-in ________. constructor constructor
Create an empty map named species. const species = new Map(); constspecies=newMap\(\);
When intantiating a map, you assign key-value pairs using an array of ______. arrays arrays
Assign a string key and integer value to a map that has already been declared. Make up the map name, string, and integer. playersOnField.set("football", 11); [a-z_$][a-zA-Z0-9_$]*\.set\(•.*•,(0|-?[1-9][\d]*)\);
Chain two key-value assignments. The keys are strings; the values are integers. Make up the map name, strings, and integers. playersOnField.set("football", 11).set("baseball", 9); [a-z_$][a-zA-Z0-9_$]*\.set\(•.*•,(0|-?[1-9][\d]*)\)\.set\(•.*•,(0|-?[1-9][\d]*)\);
Fill in the blank to assign a second key-value pair. Make up the string key and the integer value const playersOnField = new Map([
  ["football", 11],
   ___________
]);
["baseball", 9] \[•.*•,(0|-?[1-9][\d]*)\]
Intantiate a map that has a single key-value pair. The key is a string. The value is an integer. Make up everything. const playersOnField = new Map([
  ["football", 11]
]);
const[a-z_$][a-zA-Z0-9_$]*=newMap\(\[[\r\n]\[•.*•,(0|-?[1-9][\d]*)\][\r\n]\]\);
  1. Above my code declare an empty map named fruitColors.
  2. In a second statement, assign the map a key, "banana", and a color, "yellow."
  3. Click the Result button (or, after revising, don't click, just wait).
  4. If you've coded correctly, an alert will display "yellow".
  5. Dismiss the alert by clicking OK.
  6. For help with this code, see Chapter 101 in the book.
  1. Above my code, instantiate a map that declares a map named fruitColors and in the same statement assigns it a key-value pair: "banana" and "yellow".
  2. Click the Result button (or, after revising, don't click, just wait).
  3. If you've coded correctly, an alert will display "yellow".
  4. Dismiss the alert by clicking OK.
  5. For help with this code, see Chapter 101 in the book.