Tell us what’s happening:
I am not able clear the last 2 tests even though result is correct
Your code so far
function pyramid(character,rowCount,boolean){
const rows = []
function padRow(rowNumber, rowCount) {
return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber);
}
for (let i = 1; i <= rowCount; i++) {
if (boolean==true) {
rows.unshift(padRow(i, rowCount));
} else {
rows.push(padRow(i, rowCount));
}
}
let result = ""
for (const row of rows) {
result = result + `\n` + row;
}
return result
}
pyramid("o", 4, false)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Challenge Information:
Build a Pyramid Generator - Build a Pyramid Generator