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

What is the keyword for extracting the day of the month? getDate getDate
What is the keyword for extracting the year? getFullYear getFullYear
The Date object has been assigned to the variable d. Code a statement that extracts the hours and assigns it to hrs, which hasn't been declared beforehand. let hrs = d.getHours(); lethrs=d\.getHours\(\);
The Date object has been assigned to the variable d. Extract the day number and assign it to x, which hasn't been declared beforehand. let x = d.getDay(); letx=d\.getDay\(\);
The Date object has been assigned to the variable now. Display the year in an alert. alert(now.getFullYear()); alert\(now\.getFullYear\(\)\);
The Date object has been assigned to the variable x. Code the first line of an if statement that tests whether it's the last quarter of the year. if (x.getMonth() > 8) { if\(x\.getMonth\(\)>8\){
The Date object has been assigned to the variable d. Code the first line of an if statement that tests whether it's before noon. if (d.getHours() < 12) { if\(d\.getHours\(\)<12\){if\(d\.getMinutes\(\)===0\){const theHour = d.getHours();
Code the first line of an if statement that tests whether the clock is at an hour on the dot, not a minute before or after the hour. Check minutes only. Ignore seconds and milliseconds. Make up the variable to hold the Date object. if (d.getMinutes() === 0) { if\([a-z_$][a-zA-Z0-9_$]*\.getMinutes\(\)===0\){
  1. Create a new Date object.
  2. Display the current year in an alert.
  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 Date object for the day of birth.
  6. Dismiss the alert by clicking OK.
  7. For help with this code, see Chapter 44 in the book.
  1. Create a new Date object.
  2. Extract the month number.
  3. Convert the month number to the month name.
  4. Display the month name in an alert.
  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 the month name.
  8. Dismiss the alert by clicking OK.
  9. For help with this code, see Chapter 44 in the book.