How to display pyramid using JavaScript?

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

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

22条回答
  •  广开言路
    2020-11-29 12:16

    If you want to print out a right angle triangle using symbols or single digits. You can use the following code.

    let pyramid = '';
    for(pyramid.length=0; pyramid.length<=7 ; pyramid+='#'){
      console.log(pyramid);
    }
    

提交回复
热议问题