JS Built-ins
StringStringbeginner

String() β€” convert boolean 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 β€” Boolean Coercion

String(true) β†’ 'true', String(false) β†’ 'false'.

Challenge: Implement boolToString(b) that uses String(b) to convert a boolean.

boolToString(true)  // β†’ 'true'
boolToString(false) // β†’ 'false'
πŸ’‘ Hints (1)
  • β€’ `String(true)` produces the literal string `"true"`, not `1`.