Back to Freecodecamp

Step 33

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

latest1.6 KB
Original Source

--description--

To generate a pyramid, you will need to create multiple rows. When you have to perform a task repeatedly until a condition is met, you will use a <dfn>loop</dfn>. There are many ways to write a loop.

You are going to start with a basic for loop. for loops use the following syntax:

js
for (iterator; condition; iteration) {
  logic;
}

In the upcoming steps, you'll explore each component of a loop in detail. For now, construct a for loop that includes the terms "iterator", "condition", and "iteration" for the three components. Keep the loop <dfn>body</dfn>, the section within the curly braces {}, empty.

--hints--

You should have a for loop.

js
assert.match(__helpers.removeJSComments(code), /for/);

The first component of your for loop should be the string "iterator".

js
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*('|")iterator\1/);

The second component of your for loop should be the string "condition".

js
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*('|")iterator\1\s*;\s*('|")condition\2/);

The third component of your for loop should be the string "iteration".

js
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*('|")iterator\1\s*;\s*('|")condition\2\s*;\s*('|")iteration\3\s*\)/);

The body of your for loop should be empty.

js
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*('|")iterator\1\s*;\s*('|")condition\2\s*;\s*('|")iteration\3\s*\)\s*\{\s*\}/);

--seed--

--seed-contents--

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

--fcc-editable-region--

--fcc-editable-region--