0

How can I print the star in a Pyramid Shape in JS. When my code runs it show all stars in one line.How can resolve it?

(Here is my code) function piramid() { var rows=5; for(var i=1;i<=rows;i++) { for(var j=i;j<=rows;j++) { document.write(""); } for(var k=1;k<=i;k++) { document.write("*"); document.write(""); } document.write("\n"); } } piramid();

3rd Dec 2019, 7:46 AM
Imran Ahmed Shaikot
Imran Ahmed Shaikot - avatar
2 Respuestas
0
Use in last document.write this one: document.write("<pre>\n<\/pre>");
3rd Dec 2019, 10:03 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
Ok...Thanks but my same Its prints a triangle right now not pyramid....
3rd Dec 2019, 10:40 AM
Imran Ahmed Shaikot
Imran Ahmed Shaikot - avatar