Build a Pyramid Generator - Build a Pyramid Generator

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

if you write your console.logs like this:

console.log(JSON.stringify(pyramid("o", 4, false)));
console.log(JSON.stringify(pyramid("p", 5, true)));

you can compare with the two strings shown in the tests

or like this you have actual and expected on top of each other:

console.log(JSON.stringify(pyramid("o", 4, false)));
console.log(JSON.stringify("\n   o\n  ooo\n ooooo\nooooooo\n"));
console.log(JSON.stringify(pyramid("p", 5, true)));
console.log(JSON.stringify("\nppppppppp\n ppppppp\n  ppppp\n   ppp\n    p\n"));