Build a Pyramid Generator - Build a Pyramid Generator

Tell us what’s happening:

Hello,

My code solution is working and returns the correct output, however it doesn’t pass the lab tests.
Perhaps this is a bug?

Your code so far

let pyramid = (str, int, bool) => {
  let pString = "";
  if(bool) {
    let v = int*2-1
    for(let i=0; i<int; i++) {
      pString += " ".repeat(i) + str.repeat(v) + "\n"
      v-=2;
    }
  } else {
    let v = 1
    for(let i=int; i>0; i--) {
      pString += " ".repeat(i) + str.repeat(v) + "\n"
      v+=2;
    }
  }
  
  return pString;
}

console.log(pyramid("o", 4, false))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36

Challenge Information:

Build a Pyramid Generator - Build a Pyramid Generator

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"));

You can add this to the end of your script to compare actual to expected.