Build a Pyramid Generator - Build a Pyramid Generator

Tell us what’s happening:

Build a Pyramid Generator.
My code is not passing the test but when I run the tests it looks to be working well. Help me on where it is failing from.

function pyramid(patternCharacter, integer, Boolean){ let x = " "; if (Boolean == false){ for (let i = 0; i <= integer; i++) { let w = integer - i; let u = x.repeat(w); let y = (i * 2) - 1; if (i == 0){ console.log( \n); } else if (i == 1){ console.log( ${u}${patternCharacter}\n`);
}
else if (i >= 2){
let

Your code so far

function pyramid(patternCharacter, integer, Boolean){
  let x = " ";
  if (Boolean == false){
    for (let i = 0; i <= integer; i++) {
      let w = integer - i;
      let u = x.repeat(w);
      let y = (i * 2) - 1;
     if (i == 0){ 
  console.log(`\n`);
} 
else if (i == 1){
  console.log(`${u}${patternCharacter}\n`);
}
else if (i >= 2){
  let z = patternCharacter.repeat(y)
 console.log(`${u}${z}\n`);
}

}
  }
  else if (Boolean == true){
for (let i = integer; i >= 0; --i) {
  let w = integer - i;
      let u = x.repeat(w);
      let y = (i * 2) - 1
    if (i == 0){ 
  console.log(`\n`);
} 
else if (i == 1){
  console.log( `${u}${patternCharacter}\n`);
}
else if (i >= 2){
  let z = patternCharacter.repeat(y)
 console.log( `${u}${z}\n`);
}
}
  }
  return "";
}

console.log(pyramid("p", 5, false));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:139.0) Gecko/20100101 Firefox/139.0

Challenge Information:

Build a Pyramid Generator - Build a Pyramid Generator

What are you returning from this function?

A pyramid with the vertex up or down basing on the boolean value.

You can add this code to the bottom of your script file so you can compare what the tests expect to what your code is producing.

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

And I strongly suggest you give meaningful names to your variables. Meaningful variable names will make your code more readable and understandable for your future self and your co-developers. For example, rather than Boolean, doesn’t isInverted give a better sense of what that variable is being used for?

Thank you. This has helped me to see where the mistake is.