mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-23 21:04:36 -05:00
1.4 KiB
1.4 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 660f53ad3d39175c5d4335ac | Step 117 | 1 | step-117 |
--description--
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.
--hints--
You should not have any single-line comments in your code.
assert.notMatch(__helpers.removeJSComments(code), /\/\//);
You should not have any multi-line comments in your code.
assert.notMatch(__helpers.removeJSComments(code), /(?:\\\*|\/\*)/);
You should not have any comments in your code.
assert.equal(code, __helpers.removeJSComments(code));
--seed--
--seed-contents--
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 + "\n" + row;
}
console.log(result);