Tell us what’s happening:
Output looks good but code not passing. Thanks for your help!
Your code so far
function pyramid (str, int, bool) {
let newStr = "";
if (bool === false) {
for (let i = 1; i < int * 2; i +=2 ) {
let space = ((int * 2 - 1) - i) / 2;
newStr+=`\n${" ".repeat(space)}${str.repeat(i)}`;
}
} else if (bool === true) {
for (let i = int * 2 - 1; i > 0; i -= 2 ) {
let space = ((int * 2 - 1) - i) / 2;
newStr+=`\n${" ".repeat(space)}${str.repeat(i)}`;
}
}
return newStr;
}
console.log(pyramid("o", 4, false))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:151.0) Gecko/20100101 Firefox/151.0
Challenge Information:
Build a Pyramid Generator - Build a Pyramid Generator