String.prototype.padStartbeginner'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.
str.padStart(targetLength, padString?) pads the start of str with padString (default: space) until the total length reaches targetLength.
Challenge: Implement zeroPad(n, width) that zero-pads a number to the given width.
zeroPad(5, 3) // β '005'
zeroPad(42, 4) // β '0042'