JS Built-ins
StringString.prototype.concatbeginner

String.prototype.concat() β€” concat with empty 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() β€” Identity

Concatenating with an empty string returns a copy of the original.

Challenge: Implement withEmpty(str) that returns str.concat('').

withEmpty('hello') // β†’ 'hello'
πŸ’‘ Hints (1)
  • β€’ Concatenating with `""` is a no-op β€” the result equals the original string.