JS Built-ins
TypeCoercionintermediate

Explicit String Conversion

String Conversion

Multiple ways to convert values to strings:

  • String(value) - explicit conversion
  • .toString() - method on objects and primitives
  • Template literals: `${value}`

Key conversions:

  • String(null) is 'null'
  • String(undefined) is 'undefined'
  • String(true) is 'true'
  • String(42) is '42'

Challenge: Convert null, undefined, a boolean, and a number to strings.

πŸ’‘ Hints (4)
  • β€’ String() converts any value to a string representation.
  • β€’ null becomes the string "null", not an empty string.
  • β€’ undefined becomes the string "undefined".
  • β€’ Booleans become "true" or "false".