var i;
for(i=10; i>=0; i= i-1){
var s;
for(s=0; s<i; s = s+1){
document.write("*");
}
//i want this to print a new line
/document.write(?);
}
I am printing a pyramid of stars, I can't get the new line to print.
var i;
for(i=10; i>=0; i= i-1){
var s;
for(s=0; s<i; s = s+1){
document.write("*");
}
//i want this to print a new line
/document.write(?);
}
I am printing a pyramid of stars, I can't get the new line to print.
Use
"\n"
:Note, it has to be surrounded in double quotes for it to be interpreted as a newline.No it doesn't.your solution is
won't work if you're executing it (
document.write();
) multiple times.I'll suggest you should go for:
P.S I know people have stated this answer above but didn't find the difference anywhere so :)