Tell us what’s happening:
So as far as I’m concerned this code works. Which is no surprise, because I copied large part of it from previous similar exercise. Still I can’t get through checks 3 and 4. Can anyone tell me why?
Your code so far
let pyramid = (character, count, inverted) => {
let rows = [];
function padRow(rowNumber, rowCount) { return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); }
for (let i = 1; i <= count; i++) { if (inverted) { rows.unshift(padRow(i, count)); } else { rows.push(padRow(i, count)); } }
let result = "";
for (let j = 0; j < count; j++) {
if (j === 0) {result = "\n" + rows[j] + "\n";}
else {result = result + rows[j] + "\n"}
}
return result
}
console.log(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/148.0.0.0 Safari/537.36 Edg/148.0.0.0
Challenge Information:
Build a Pyramid Generator - Build a Pyramid Generator