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

If the value of nums is [1, 2, 3, 4] what is the value of test when the following code executes? let test = nums.includes(5); false false
What is the value of anArray when the following code executes? let anArray = Array.from("Hi"); ["H","i"] \[•H•,•i•\]
Check whether "salt" is an element in the variable ingredients and assign the result to a new variable, isSalt. let isSalt = ingredients.includes("salt"); letisSalt=ingredients\.includes\(•salt•\);
A string has been assigned to the variable x. Convert the string into an array and assign the array to y, which hasn't been previously declared. let y = Array.from(x); lety=Array\.from\(x\);
Convert 1, 2, 3 to [1,2,3] and assign the array to nums, a variable that hasn't been previously declared. let nums = Array.of(1, 2, 3); letnums=Array\.of\(1,2,3\);
Convert a string to an array of the individual characters and assign the array to a variable that hasn't previously been declared. Make up everything. let chars = Array.from("Ko"); let[a-z_$][a-zA-Z0-9_$]*=Array\.from\(•.*•\);
Check whether an integer is present in an array and assign the result to a new variable. Make up everything. let test = nums.includes(100); let[a-z_$][a-zA-Z0-9_$]*=[a-z_$][a-zA-Z0-9_$]*\.includes\((0|-?[1-9][\d]*)\);
Assign a string to a variable that hasn't previously been delcared. In a single statement display an array created from it. let eyeColor = "brown";
alert(Array.from(eyeColor));
let([a-z_$][a-zA-Z0-9_$]*)=•.*•;[\r\n]alert\(Array\.from\(\1\)\);
  1. Convert a string to an array, assigning the array to a new variable.
  2. Display the array in an alert, specifying the variable.
  3. Click the Result button (or, after revising, don't click, just wait).
  4. Wait a moment.
  5. If you've coded correctly, an alert will display the array.
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 25 in the book.
  1. Create a new array consisting of integers.
  2. Check whether a certain integer is included in the array, assigning the result to a new variable.
  3. Display the result in an alert.
  4. Click the Result button (or, after revising, don't click, just wait).
  5. Wait a moment.
  6. If you've coded correctly, an alert will display true or false, depending on whether the integer is included in the array.
  7. Dismiss the alert by clicking OK.
  8. For help with this code, see Chapter 25 in the book.