Tell us what’s happening:
So i managed to get true to output my pyramid the way i like. But how about false? Its getting really annoying, I’ve been trying to solve this problem for a bit of time!
Your code so far
function pyramid(ltr, rows, bool) {
let newStr = ''
switch (bool) {
case true:
for (let i = 0; i < rows; i++) {
newStr += `${' '.repeat(i)}${ltr.repeat(rows * 2 - 1 - i * 2)}\n`
}
break;
case false:
for (let i = 0; i < rows; i++) {
newStr += `${' '.repeat(rows * 2 - 1 - i)}${ltr.repeat(rows * 2 - 1)}\n`
}
break;
}
return newStr
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 Edg/139.0.0.0
Challenge Information:
Build a Pyramid Generator - Build a Pyramid Generator
https://www.freecodecamp.org/learn/full-stack-developer/lab-pyramid-generator/lab-pyramid-generator