0
How to add a space between document.write()
The issue is that whenever I create a new document text like: var x = 100; var y = x + 500+300+100; document.write(y); document.write("Testing the space separator"); I get this "1000Testing the space separator" for example. How should I proceed? Thanks
8 Respostas
0
From this you can use space anywhere
var z = "<br>";
var x = 100;
var y = x + 500+300+100;
document.write(y);
document.write(z);
document.write("Testing the space separator");
+ 7
use \n after y
or before testing
+ 2
You got 2 more options, putting the space in the second write:
var x = 100;
var y = x + 500+300+100;
document.write(y);
document.write(" Testing the space separator");
Or, add another write:
var x = 100;
var y = x + 500+300+100;
document.write(y);
document.write(" ");
document.write("Testing the space separator");
+ 1
To get on the next line, write some HTML.
document.write("<br>");
+ 1
Thanks, John and TurtleShell, the document.write("<br>") did the trick.
+ 1
var z = "<br>";
var x = 100;
var y = x + 500+300+100;
document.write(y + z);
document.write("Testing the space separator");
0
document.write(y + " ");
or a newer JS feature called string templates/interpolation (for this case probably an overkill)
document.write(`${y} `);
0
Thanks for that but if I want to set it like
1000
Testing the space separator
What should I use?