Tell us what’s happening:
This is the correct solution to the problem though it is not accepted.
Your code so far
function pyramid(pattern,rows,bool){
let line = ""
let mainPat = ""
if(bool===false){
for(let i=0;i<rows;i++){
for(let j=rows-i-1;j>=0;j--) line = line + " "
for(let k=0;k<2*i+1;k++) line = line + pattern
mainPat=mainPat + line + "\n"
line=""
}}
else{
for(let i=rows;i>0;i--){
for(let j=0;j<=rows-i-1;j++) line = line + " "
for(let k=0;k<2*i-1;k++) line = line + pattern
mainPat=mainPat + line + "\n"
line=""
}
}
return mainPat
}
console.log(pyramid("o", 4, false))
console.log(pyramid("p", 5, true))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36
Challenge Information:
Build a Pyramid Generator - Build a Pyramid Generator