I want to create two pyramids using for loop in JavaScript and print it in the console as given below:
1 Answer
for (var i = 4; i >= 1; i = i - 1) {
for (var j = 4; j >= i; j = j - 1) {
document.write(j);
}
//i want this to print a new line
document.write("<br>");
}
2 Comments
Keyur Buch
For first triangle try this code
Keyur Buch
For your second trianle output take third variable c=1 before loop initialisation and print with (print c) and c++
