Here is the code to display pyramid but its not exactly producing required output.
function generatePyramid() {
var totalNumberofRows = 5;
var arr = new Array();
for (var i = 1; i <= totalNumberofRows; i++) {
for (var j = 1; j <= i; j++) {
arr.push(j);
console.log(j);
}
console.log("
");
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…