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

Code a statement that arranges the elements of the array cities in ascending alphabetical order. cities.sort(); cities\.sort\(\);
After the following statements execute, what is the second element? const names = ["Meg", "Bo", "Ed"];
names.reverse();
"Bo" •Bo•
To sort the following array in descending alphabetical order, you need to code 2 statements. What is the first statement? const names = ["Meg", "Bo", "Ed"]; names.sort(); names\.sort\(\);
To sort the following array in descending alphabetical order, you need to code 2 statements. What is the second statement? const names = ["Meg", "Bo", "Ed"]; names.reverse(); names\.reverse\(\);
Sort an array in ascending alphabetical order. Make up the array name. places.sort(); [a-z_$][a-zA-Z0-9_$]*\.sort\(\);
Sort an array in descending alphabetical order. Make up the array name. places.sort();
places.reverse();
([a-z_$][a-zA-Z0-9_$]*)\.sort\(\);[\r\n]\1\.reverse\(\);
After the following statements execute, what is the first element in the array? const numbers = [25, 100, 3];
numbers.sort();
100 100
After the following statements execute, what is the first element in array1? const array1 = ["Meg", "Bo", "Ed"];
const array2 = array1.sort();
"Bo" •Bo•
  1. Create an array of strings.
  2. Sort the array into ascending alphabetical order.
  3. Display the array 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 the display the array sorted into ascending alphebetical order.
  7. Dismiss the alert by clicking OK.
  8. For help with this code, see Chapter 54 in the book.
  1. Create an array of strings.
  2. Sort the string into descending alphabetical order.
  3. Display the array 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 the array sorted into descending alphabetical order.
  7. Dismiss the alert by clicking OK.
  8. For help with this code, see Chapter 54 in the book.