Tell us what’s happening:
i am a little lost, 3 and 4 can’t pass, i tried different variations to no avail kindly help.
Your code so far
function pyramid(str, int, bool) {
let pyrs = [];
let result = "";
let play ="";
if(bool === false) {
for(let i = 0; i <= int; i++) {
play = play + str.repeat(i);
pyrs.push(play);
} }else if(bool === true) {
for(let j = int; j >= 0; j--) {
play = play + str.repeat(j);
pyrs.push(play);
}
}
for(let pyr of pyrs) {
result = result + pyr +`\\n`;
}
return result;
}
const getPyramid = pyramid("O", 4, false);
console.log(getPyramid);
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
Challenge Information:
Build a Pyramid Generator - Build a Pyramid Generator