Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (13.1k points)

I was trying to print the pyramid of stars, but was not able to add the new line.

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(?);

}

Can anyone help me with this?

1 Answer

0 votes
by (26.7k points)

Basically, you can use \n for newline.

document.write("\n");

Also, if you are using HTML then,

document.write("<br>");

I hope this will help.

Want to become a Java expert? join Java Training now!!

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Feb 21, 2021 in Java by dante07 (13.1k points)
0 votes
1 answer
asked Feb 16, 2021 in Java by dante07 (13.1k points)

Browse Categories

...