JS Built-ins
StringString.prototype.padStartbeginner

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

πŸ“– Usage Example
'5'.padStart(3, '0')       // β†’ '005'
'hi'.padStart(5, '-')     // β†’ '---hi'
'hello'.padStart(3)       // β†’ 'hello'

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

String.prototype.padStart() β€” Custom Fill

Pass a custom fill string to pad with something other than spaces or zeros.

Challenge: Implement padStars(str, len) that pads the start with '*'.

padStars('hi', 5) // β†’ '***hi'
πŸ’‘ Hints (1)
  • β€’ `str.padStart(len, "*")` fills with asterisks on the left.