JS Built-ins
← Date36 / 120
DategetDaybeginner

getDay() β€” Monday is 1

πŸ“– 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()

Returns the day of the week (0 = Sunday, 6 = Saturday). Jan 1, 2024 was a Monday.

Challenge: Verify that new Date(2024, 0, 1).getDay() returns 1 (Monday).

πŸ’‘ Hints (1)
  • β€’ Jan 1, 2024 was a Monday. getDay() returns 1 for Monday (0=Sun, 1=Mon, …, 6=Sat)