JS Built-ins
StringString.prototype.padEndbeginner

String.prototype.padEnd() β€” no padding when already long enough

πŸ“– Usage Example
'5'.padEnd(3, '0')       // β†’ '500'
'hello'.padEnd(8, '-')   // β†’ 'hello---'
'hi'.padEnd(2)           // β†’ 'hi'

Use padEnd() to pad the end of a string with a fill character until it reaches the target length.

String.prototype.padEnd() β€” No-Op

If str.length >= targetLength, .padEnd() returns str unchanged.

Challenge: Implement padToTen(str) that pads to length 10.

padToTen('hello world!') // β†’ 'hello world!'  (unchanged, already > 10)
padToTen('hello')        // β†’ 'hello     '
πŸ’‘ Hints (1)
  • β€’ If the string is already at or beyond the target length, `.padEnd()` returns it as-is.