JS Built-ins
StringStringintermediate

String() β€” convert array to string

πŸ“– Usage Example
String(42)         // β†’ '42'
String(true)       // β†’ 'true'
String(null)       // β†’ 'null'
String(undefined)  // β†’ 'undefined'

Use String() to safely convert any value to its string representation.

String Constructor β€” Array Coercion

String([1, 2, 3]) calls .toString() on the array, joining with commas: '1,2,3'.

Challenge: Implement arrayToStr(arr) that uses String(arr) to convert a number array.

arrayToStr([1, 2, 3])  // β†’ '1,2,3'
arrayToStr([42])       // β†’ '42'
πŸ’‘ Hints (1)
  • β€’ `String(arr)` internally calls `arr.toString()`, which joins elements with commas.