Re-creating Lodash - invalid count value?

Hi, I’m stuck on the .pad exercise in recreating the lodash library (https://www.codecademy.com/paths/web-development/tracks/web-dev-js-arrays-loops-objects/modules/pjs-javascript-capstone/projects/lodash)

The problem in question is on my:

' '.repeat(endPaddingLength) 

Where the test finds that the repeat has an invalid count value. What does that mean and how do I fix it? I haven’t found any good answers, and the video doesn’t help me understand the error unfortunately. My code is as follows

  pad(string, length) {
    if (string.length >= length) {
      return string;
    };
    let startPaddingLength = Math.floor((length - string.length/2));
    let endPaddingLength = length - string.length - startPaddingLength;
    let paddedString = ' '.repeat(startPaddingLength) + string + ' '.repeat(endPaddingLength);
    return paddedString;
  },

Thanks in advance for the help!

/Elis

Have your tried console.log on endPaddingLength to see its value?

If it works for your example, maybe the test inputs use some parameters that break this bit of code. So you’d have to try different parameters that could could break your endPaddingLength.

Ok, how do i console.log with the bash console where you test the parts?

Nevermind I found the error! The problem was a ) that was off. Instead of dividing length - string.length by two i divided string.length by 2 like this:

let startPaddingLength = Math.floor((length - string.length/2));

simply changed the ) and it was fixed, like this;

let startPaddingLength = Math.floor((length - string.length)/2);

Thanks anyhow!