JS Built-ins
StringString.prototype.padEndbeginner

String.prototype.padEnd() β€” custom fill string

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

Pass a second argument to use a custom fill string instead of spaces.

Challenge: Implement padDots(str, len) that pads the end with dots '.'.

padDots('hi', 6) // β†’ 'hi....'
πŸ’‘ Hints (1)
  • β€’ `str.padEnd(length, ".")` fills with dots.