JS Built-ins
StringString.prototype.padStartbeginner

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

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

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

Challenge: Implement padToFive(str) that pads to length 5.

padToFive('hi')      // β†’ '   hi'
padToFive('hello!')  // β†’ 'hello!'  (unchanged)
πŸ’‘ Hints (1)
  • β€’ If the string is already 5 or more chars, `.padStart(5)` is a no-op.