JS Built-ins
StringString.prototype.concatbeginner

String.prototype.concat() β€” coerces non-strings

πŸ“– Usage Example
const str = 'Hello'
str.concat(', ', 'World', '!')   // β†’ 'Hello, World!'
''.concat('a', 'b', 'c')          // β†’ 'abc'

Use concat() to join two or more strings together, returning a new string without modifying the originals.

String.prototype.concat() β€” Type Coercion

.concat() coerces non-string arguments to strings, similar to the + operator.

Challenge: Implement appendNumber(str, n) that concatenates a string and a number using .concat().

appendNumber('score: ', 42) // β†’ 'score: 42'
πŸ’‘ Hints (1)
  • β€’ Convert `n` to string first with `String(n)`, then concat.