String.prototype.padstart = function(targetLength, str) {
if (this.length > targetLength) {
return String(this);
} else {
if (targetLength - this.length > str.length) {
str += str.repeat((targetLength - this.length) / str.length);
}
}
return str.slice(0, (targetLength - this.length)) + String(this);
}
console.log("123".padstart(7, "abc"));