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
  • 59,258
  • 35
  • 162
  • 290
0

Try something like this:

while(myString.length < 10) {
    myString += " ";
}
chris97ong
  • 6,870
  • 7
  • 32
  • 52