How to display pyramid using JavaScript?

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

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

22条回答
  •  天涯浪人
    2020-11-29 12:13

      const pyramid = (n)=>{
      const mid = Math.floor((2*n-1)/2);
      for(let row=0; row= col)
            level+='#';
          else level +=' ';
        }
        console.log(level);
      }
    }
    pyramid(3);
    

提交回复
热议问题