Back to Freecodecamp

Step 77

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

latest1.2 KB
Original Source

--description--

JavaScript also has support for multi-line comments. A multi-line comment starts with /* and ends with */.

Unlike a single-line comment, a multi-line comment will encapsulate multiple lines.

Use /* and */ to turn your current for loop, including the body, into a multi-line comment.

--hints--

You should start a multi-line comment with /*.

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

You should end a multi-line comment with */.

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

Your entire for loop should be commented out.

js
const stripped = __helpers.removeJSComments(code);
assert.lengthOf(stripped.match(/for/g), 1);
assert.notMatch(stripped, /rows\.push/);
assert.notMatch(stripped, /i <= count/);

--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);
}

// TODO: use a different type of loop
--fcc-editable-region--
for (let i = 1; i <= count; i++) {
  rows.push(padRow(i, count));
}
--fcc-editable-region--

let result = ""

for (const row of rows) {
  result = result + row + "\n";
}

console.log(result);