Tell us what’s happening:
hey im struggling with the build a pyramid Generator in the JavaScript Certification.
I don’t really understand what it wants me to do. as far as i can see the code i have should pass. I also cant find any posts on this, it seems like there is another pyramid generator build in some other certification program involving javascript.
just need a hint at what im doing wrong please and thank you.
Your code so far
function pyramid(character, count, isInverted){
let returnString = "";
if(isInverted === false){
for (let i = 1; i <= count; i++) {
const spaces = " ".repeat(count - i);
const hashes = character.repeat(2 * i - 1);
returnString += spaces + hashes + spaces + "\n";
}
} else if(isInverted === true){
for (let i = count; i > 0; i--) {
const spaces = " ".repeat(count - i);
const hashes = character.repeat(2 * i - 1);
returnString += spaces + hashes + spaces + "\n";
}
} else{
return "not boolean input";
}
return returnString;
}
console.log(pyramid("p", 4, true));
Your browser information:
User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
Challenge Information:
Build a Pyramid Generator - Build a Pyramid Generator