Recreating the lodash library

I am getting an error when implementing the pad() method within lodash, it refers to the use of repeat within the method,

The error is related to the following line:

const paddedString =' '.repeat(startPaddingLength) + str + ' '.repeat(endPaddingLength);

The error states:

RangeError: Invalid count value at String.repeat

I tested the line of code you posted, and see no problems with it specifically. Will need to see the rest of the code in order to help.

1 Like

Not to worry, I managed to make it work in the end

1 Like

how did you fix it?
Iā€™m getting the same error.