JS Built-ins
← Array222 / 226
ArrayArray.prototype.toLocaleStringbeginner

Localize a Number Array

πŸ“– Usage Example
const nums = [1000, 2000, 3000]
nums.toLocaleString('en-US')  // β†’ '1,000,2,000,3,000'

Use toLocaleString() to format array elements using locale-aware number or date formatting.

Array.prototype.toLocaleString

toLocaleString() converts each element to a locale-sensitive string and joins them with a locale-appropriate separator.

Implement localizeArray that returns arr.toLocaleString().

πŸ’‘ Hints (2)
  • β€’ `toLocaleString()` on an array calls `toLocaleString()` on each element and joins with a locale separator.
  • β€’ The exact output depends on the runtime locale, so avoid testing the precise formatted value.