How to display pyramid using JavaScript?

前端 未结 22 873
长情又很酷
长情又很酷 2020-11-29 11:45

Here is the code to display pyramid but its not exactly producing required output.

22条回答
  •  无人及你
    2020-11-29 12:08

    This could be done using a single for loop.

    var num = "";
    var size = prompt("Enter the size of the pyramid");
    for(var i=1; i<=size; i++)
    {
      num = num + i
      console.log(num);
    }

提交回复
热议问题