Lodash project PAD error

pad(string, length){

  if(length <= string.length){

    return string

  }

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

  var endPaddingLength =  length - string.length - startPaddingLength;

  var paddedString =' '.repeat(startPaddingLength)+ string+' '.repeat(endPaddingLength);

  return paddedString;

}

gives following error:

/home/ccuser/workspace/underscore-javascript-capstone/_.js:31
  var paddedString =' '.repeat(startPaddingLength)+ string+' '.repeat(endPaddingLength);
                                                               ^

RangeError: Invalid count value
    at String.repeat (native)
    at Object.pad (/home/ccuser/workspace/underscore-javascript-capstone/_.js:31:64)
    at Object.<anonymous> (/home/ccuser/workspace/underscore-javascript-capstone/test/pad.js:15:79)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:427:7)