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

The statement below creates a Date _____. const now = new Date(); object object
When you extract the day from a Date object, you get an integer, not a string. What is the number that means "Sat"? Answer with a numeral, like 1. 6 6
Fill in the blank to create a new Date object. const dObj = new _______; Date() Date\(\)
Fill in the blank to create a new Date object. const dObj = ____________; new Date() newDate\(\)
Code a statement that creates a new Date object for your birthday. Make up the variable name. Example: const specialDate = new Date("June 21, 1989"); const[a-z_$][a-zA-Z0-9_$]*=newDate\(•\w+\d{2},\d{4}•\);
Given the code below, fill in the blank to extract the day of the week and assign it to the variable today. const d = new Date();
const today = _________;
d.getDay() d\.getDay\(\)
Given the code below, extract the day of the week and assign it to a variable that hasn't been declared previously. Make up the name of the variable. const d = new Date(); const today = d.getDay(); const[a-z_$][a-zA-Z0-9_$]*=d\.getDay\(\);
The day has been extracted from the Date object and assigned to the variable dayNumber. The names of the days of the week have been assigned to the array dayNames. Fill in the blank. alert("Today is " + ___________); dayNames[dayNumber] dayNames\[dayNumber\]
  1. Create a new Date object.
  2. Code an alert that displays the number of the current day.
  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 number of the current day.
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 43 in the book.
  1. Create a new Date object.
  2. Extract the day.
  3. Convert the day to a day name.
  4. Code an alert that displays the day name.
  5. Click the Result button (or, after revising, don't click, just wait).
  6. Wait a moment.
  7. If you've coded correctly, an alert will display today's name.
  8. Dismiss the alert by clicking OK.
  9. For help with this code, see Chapter 43 in the book.