Since I am limited to use ECMAScript version 7, and I wanted to use String methods like padStart() introduced in ES 8
I added the folowing code for the custom padStart(digits,character) method which was working as expected:
String.prototype.padStart = function(digits,fill){
value = this;
while (value.length < digits){
value = fill+value;
}
return value
}
Now I added a second method padEnd(digits,character) to my code:
String.prototype.padEnd = function(digits,fill){
value = this;
while (value.length < digits){
value = value + 'X';
}
return value + 'X'
}
And I was expecting I were able to uses both new methods on String-Objects, but I found that only the code of the first method is used, even if I use the padEnd() method on the String object.
What am I doing wrong?