Back to Freecodecamp

Step 110

curriculum/challenges/english/blocks/learn-introductory-javascript-by-building-a-pyramid-generator/660f4f79e2a82a4e92290f44.md

latest1.5 KB
Original Source

--description--

Sometimes you may wish to bring back previous code that you commented out. You can do so by removing the /* and */ around that code. This is called <dfn>uncommenting</dfn>.

Uncomment only your first for loop. Leave the single line comment and the other two multi line comments in place.

--hints--

You should uncomment your first for loop.

js
const stripped = __helpers.removeJSComments(code);
assert.match(stripped, /for\s*\(\s*let\s+i\s*=\s*1;\s*i\s*<=\s*count;\s*i\+\+\s*\)/)

You should not remove your single-line comment.

js
assert.match(code, /\/\//);

You should not uncomment your while loop.

js
const stripped = __helpers.removeJSComments(code);
assert.notMatch(stripped, /while/);

You should not uncomment your second for loop.

js
const stripped = __helpers.removeJSComments(code);
assert.lengthOf(stripped.match(/for\s*\(/g), 2)

--seed--

--seed-contents--

js
const character = "#";
const count = 8;
const rows = [];

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++) {
  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);