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

Fill in the blank to complete the first line for creating a new array from an existing array, nums. const biggerNums = ___________(function(element) { nums.map nums\.map
Fill in the blank to complete the first line for creating a new array from an existing array. Make up the name of the existing array. const newArray = ___________(function(element) { nums.map [a-z_$][a-zA-Z0-9_$]*.map
Fill in the blank to complete the first line for creating a new array from an existing array. Make up the name of both arrays. ___________________________(function(element) { const biggerNums = nums.map const[a-z_$][a-zA-Z0-9_$]*=[a-z_$][a-zA-Z0-9_$]*\.map
Fill in the blank to complete the first line for creating a new array from an existing array. Make up the name of the parameter. const biggerNums = nums.map(____________) { function(element function\([a-z_$][a-zA-Z0-9_$]*
Code the first line for creating a new array from an existing array. Make up all the names. const biggerNums = nums.map(function(element) { const[a-z_$][a-zA-Z0-9_$]*=[a-z_$][a-zA-Z0-9_$]*\.map\(function\([a-z_$][a-zA-Z0-9_$]*\){
Code a complete map() statement that does nothing but copy the elements of an existing array to a new array. Use an anonymous function. Make up the names. const newArr = arr.map(function(el) {
  return el;
});
const[a-z_$][a-zA-Z0-9_$]*=[a-z_$][a-zA-Z0-9_$]*\.map\(function\(([a-z_$][a-zA-Z0-9_$]*)\){[\r\n]return\1;[\r\n]}\);
Code a complete statement that creates a new array by multiplying the values of an existing array by an integer. Use an anonymous function. Make up everything. const newArr = arr.map(function(el) {
  return el * 7;
});
const[a-z_$][a-zA-Z0-9_$]*r=[a-z_$][a-zA-Z0-9_$]*\.map\(function\(([a-z_$][a-zA-Z0-9_$]*)\){[\r\n]return\1\*(0|-?[1-9][\d]*);[\r\n]}\);
Code a complete statement that creates a new array by concatenating the string "True: " with each string value of an existing array. Use an anonymous function. Make up the names. const newArr = arr.map(function(el) {
  return "True: " + el;
});
const[a-z_$][a-zA-Z0-9_$]*=[a-z_$][a-zA-Z0-9_$]*\.map\(function\(([a-z_$][a-zA-Z0-9_$]*)\){[\r\n]return•True:•\+\1;[\r\n]}\);
  1. Code an array of integers.
  2. Code a statement that maps the array onto a new array that doubles the values of the original. Use an arrow function.
  3. Display the new array in an alert.
  4. Click the Result button (or, after revising, don't click, just wait).
  5. When 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 103 in the book.
  1. Code an array of integers.
  2. Code a statement that maps the array onto a new array that concatenates a string—the same string—with each original value. Use an arrow function.
  3. Display an element of the new array in an alert.
  4. Click the Result button (or, after revising, don't click, just wait).
  5. When you've coded correctly, an alert will display an element of the new array.
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 103 in the book.