In this article, I am going to show you how to create a pyramid structure from javascript.

Create Pyramid structure from javascript simple nested loop

var rows = 10

for(var i=0; i<=rows; i++){
	for(var k=1; k<=rows-i; k++){
		document.write(" ")
	}
	for(var j=0; j<=i; j++) {
		document.write("* ");
	}
	document.write("
") }

The above code with return a pyramid structure as shown in featured image.

Published by Santosh Shah

My name is Santosh Shah and blogs at santosh-shah.com

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.