HelloWorld
HelloWorld

Reputation: 131

How to add a white space

I want know how to add white space in JavaScript. I have this line of code:

document.write('<tr align="center"><td>' + txt2.bold().fontcolor("blue") +"                   "+ '</td><td>' +"                   "+  txt3.bold().fontcolor("blue") + '</td></tr><br>');

I want it to do it a different way is there something that I can do to add white space such as Java's "printf()" function where u can add space but doing %s-25 and it will add 25 spaces

Upvotes: 0

Views: 172

Answers (1)

Lyrkan
Lyrkan

Reputation: 1063

You could use Array.join :

new Array(20).join(' ')

or with non-breaking spaces :

new Array(20).join('&nbsp;')

Upvotes: 2

Related Questions