JS Built-ins
← Array224 / 226
ArrayArray.prototype.toLocaleStringintermediate

Format an Array of Dates

πŸ“– Usage Example
const dates = [new Date('2024-01-01'), new Date('2024-06-15')]
dates.toLocaleString('en-GB')
// β†’ '01/01/2024, 00:00:00,15/06/2024, 00:00:00'

Use toLocaleString() on arrays of Date objects to produce locale-formatted date strings.

Array.prototype.toLocaleString β€” Date Arrays

When called on an array of Date objects, toLocaleString() converts each date to a locale-sensitive date string.

Implement formatDates(dates) that returns dates.toLocaleString().

πŸ’‘ Hints (2)
  • β€’ `toLocaleString()` on an array calls `toLocaleString()` on each element.
  • β€’ Each `Date` object has its own `toLocaleString()` that formats according to the runtime locale.