Creating the Lodash library...pad()

Ok…so I’m not sure what I’m doing wrong here. Got through the first 16 ok…this one’s giving me a headache:

pad(str, length) {
if (length <= str.length) {
return str
};
const startPaddingLength = Math.floor((length - str.length)/2);
const endPaddingLength = (length - str.length) - startPaddingLength;
const paddedString = ’ '.repeat(startPaddingLength) + ‘str’ + ’ '.repeat(endPaddingLength);
return paddedString
};
Any help would be greatly appreciated.

Ok figured it out on my own lol silly me str didn’t need ’

1 Like