
March 2016. A developer gets into a naming fight with npm, and in protest he unpublishes all his tiny packages. One of them, left-pad, is eleven lines long. Within minutes Babel, React and thousands of builds around the world fall over at once, every one of them missing the same eleven lines. You are on call the night the internet forgot how to pad a string. Rebuild them.
Objective
Rebuild left-pad: copy a string into a buffer, padded on the left to a minimum width.
Steps
$ left_pad(dst, "1", 5, '0')
[00001]
$ left_pad(dst, "foo", 5, ' ')
[ foo]
$ left_pad(dst, "hello", 3, 'x')
[hello]
Expected files
Allowed functions
None. Write every helper yourself.
Loading solutions...