Right pads with zeros with no arrays or loops. Just uses repeat()
using ES6 2015, which has wide support now. Left pads if you switch the concatenation.
function pad(text, maxLength){
var res = text + "0".repeat(maxLength - text.length);
return res;
}
console.log(pad('hello', 8)); //hello000