curriculum/challenges/english/blocks/learn-introductory-javascript-by-building-a-pyramid-generator/660f53ad3d39175c5d4335ac.md
Your pyramid generator is now in a finished state, with more functionality than you originally planned! The next step is to clean up your code.
Remove all comments, both single- and multi-line, from your code.
You should not have any single-line comments in your code.
assert.notMatch(code, /\/\//);
You should not have any multi-line comments in your code.
assert.notMatch(code, /(?:\*\/|\/\*)/);
You should not have any comments in your code.
assert.equal(code, __helpers.removeJSComments(code));
You should remove code that was commented out by multi-line comments.
assert.notMatch(code, /while/);
assert.lengthOf(code.match(/for\s*\(/g), 2)
assert.lengthOf(code.match(/rows\.push/g), 1);
const character = "#";
const count = 8;
const rows = [];
let inverted = true;
function padRow(rowNumber, rowCount) {
return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber);
}
--fcc-editable-region--
// TODO: use a different type of loop
for (let i = 1; i <= count; i++) {
if (inverted) {
rows.unshift(padRow(i, count));
} else {
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--
let result = ""
for (const row of rows) {
result = result + row + "\n";
}
console.log(result);