JS Built-ins
← Date104 / 120
DatetoDateStringbeginner

toDateString() β€” result length > 0

πŸ“– Usage Example
const d = new Date(2024, 0, 15)
d.toDateString()  // β†’ 'Mon Jan 15 2024'

Use toDateString() to get a human-readable string of the date portion of a Date object in local time.

Date.prototype.toDateString()

The result is always a non-empty string.

Challenge: Verify that new Date(2024, 0, 15).toDateString().length > 0.

πŸ’‘ Hints (1)
  • β€’ toDateString() always returns a meaningful non-empty string for a valid Date