JS Built-ins
← Date105 / 120
DatetoDateStringbeginner

toDateString() β€” result is truthy

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

A non-empty string is always truthy in JavaScript.

Challenge: Verify that new Date(2024, 0, 15).toDateString() is truthy.

πŸ’‘ Hints (1)
  • β€’ Any non-empty string is truthy; toDateString() always returns a non-empty string