JS Built-ins
StringString.prototype.concatintermediate

String.prototype.concat() β€” returns a new string

πŸ“– 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() β€” Immutability

.concat() never modifies the original string. Strings in JavaScript are immutable.

Challenge: Implement concatAndCheck(a, b) that returns an object { result, originalUnchanged } where result = a.concat(b) and originalUnchanged is true if a is still its original value.

concatAndCheck('foo', 'bar') // β†’ { result: 'foobar', originalUnchanged: true }
πŸ’‘ Hints (1)
  • β€’ Strings are immutable in JavaScript. `.concat()` always returns a new value.