JS Built-ins
← Date39 / 120
DategetDaybeginner

getDay() β€” result is between 0 and 6

πŸ“– Usage Example
const d = new Date(2024, 0, 15)  // Monday
d.getDay()  // β†’ 1
// 0=Sun, 1=Mon, …, 6=Sat

Use getDay() to retrieve the day of the week (0 = Sunday through 6 = Saturday) in local time.

Date.prototype.getDay()

getDay() always returns an integer from 0 (Sunday) to 6 (Saturday).

Challenge: Verify that the result is in the range [0, 6].

πŸ’‘ Hints (1)
  • β€’ Days of week run Sunday(0) through Saturday(6) β€” 7 values total