JS Built-ins
← Array115 / 226
ArrayArray.prototype.joinbeginner

Array.prototype.join() β€” default separator

πŸ“– Usage Example
const arr = [1, 2, 3]
arr.join()    // β†’ '1,2,3'  (default separator is ',')
arr.toString() // β†’ '1,2,3'  (same result)

Calling join() without arguments uses a comma as the default separator.

Array.prototype.join() β€” default comma separator

When called with no arguments, join() uses a comma (,) as the separator β€” with no space.

Challenge: Implement joinDefault(arr) that calls arr.join() with no separator argument.

joinDefault([1, 2, 3]) // β†’ '1,2,3'
joinDefault([])        // β†’ ''
πŸ’‘ Hints (2)
  • β€’ The default separator is `","` β€” no space included.
  • β€’ Number elements are converted to strings via `.toString()` before joining.