0

If I have a string like this:

var myString = "abc";

or 

var myString = "a";

Is there a way that I can pad the string with spaces so it's always has a length of ten?

2 Answers2

0
while(str.length < 10) str += ' ';

that?

djechlin
  • 57,408
  • 33
  • 153
  • 271
0

Try something like this:

while(myString.length < 10) {
    myString += " ";
}
chris97ong
  • 6,592
  • 7
  • 29
  • 49