curriculum/challenges/english/blocks/learn-introductory-javascript-by-building-a-pyramid-generator/660f4cffb1459d45e34902d1.md
You can actually build the inverted pyramid without needing to loop "backwards" like you did.
To do this, you'll need to learn a couple of new array methods. Start by using const to declare a numbers variable. Assign it an array with the elements 1, 2, and 3. Then log the numbers array.
You should use const to declare a numbers variable.
assert.match(__helpers.removeJSComments(code), /const\s+numbers/);
Your numbers variable should be an array.
assert.isArray(numbers);
Your numbers array should have the elements 1, 2, and 3 in that order.
assert.deepEqual(numbers, [1,2,3]);
You should log your numbers array.
assert.match(__helpers.removeJSComments(code), /console\.log\(\s*numbers\s*\);?/);
const character = "#";
const count = 8;
const rows = [];
function padRow(rowNumber, rowCount) {
return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber);
}
// TODO: use a different type of loop
/*for (let i = 1; i <= count; i++) {
rows.push(padRow(i, count));
}*/
/*while (rows.length < count) {
rows.push(padRow(rows.length + 1, count));
}*/
/*for (let i = count; i > 0; i--) {
rows.push(padRow(i, count));
}*/
--fcc-editable-region--
--fcc-editable-region--
let result = ""
for (const row of rows) {
result = result + row + "\n";
}
console.log(result);