What is the problem with test 3. and 4.? while the output is right
Your code so far
function pyramid(patternChar, numOfRows, isTrueOrFalse) {
let n = numOfRows;
let row='';
if (isTrueOrFalse == false) {
for (let i = 1; i <= n; i++) {
row += ' '.repeat(n - i);
row += patternChar.repeat(i + i - 1) + '\n';
}
}
else if (isTrueOrFalse == true) {
for (let i = n; i >= 1; i--) {
row += ' '.repeat(n - i);
row += patternChar.repeat(i + i - 1) + '\n';
}
}
return row;
}
console.log(pyramid('o', 4, false));
console.log(pyramid('p', 5, true));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Challenge Information:
Build a Pyramid Generator - Build a Pyramid Generator