Tell us what’s happening:
what else do I need to do to pass this test, my code fulfills all the user stories?
Your code so far
function pyramid(pattern, rows, boolean) {
if (!boolean) {
for (let j = rows; j > 0; j--) {
let spaces = ' '.repeat(rows - j);
let chars = pattern.repeat(2 * j - 1);
console.log(spaces + chars + "\n");
}
} else {
for (let i = 1; i <= rows; i++) {
let spaces = ' '.repeat(rows - i);
let chars = pattern.repeat(2 * i - 1);
console.log(spaces + chars + "\n");
}
}
}
pyramid("t", 5, false);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Challenge Information:
Build a Pyramid Generator - Build a Pyramid Generator
Hi. Can you please link to the step number of the challenge you are stuck on.
I don’t actually know which step that is generating the problem, but I think its step 9 of Javascript fundamentals review, under the certified full stack developer curriculum
You are doing the one in the Full Stack Developer curriculum. Can you copy the link into a forum post so that people can more easily help you?
Your final result should be built into variable that your function returns, which you can test by adding this code to the bottom of your script:
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"));