Back to Freecodecamp

Step 34

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

latest1.3 KB
Original Source

--description--

Your loop now needs a proper iterator. The <dfn>iterator</dfn> is a variable you can declare specifically in your for loop to control how the loop iterates or goes through your logic.

It is a common convention to use i as your iterator variable in a loop. A for loop allows you to declare this in the parentheses (). For example, here is a for loop that declares an index variable and assigns it the value 100.

js
for (let index = 100; "second"; "third") {

}

Replace the string "iterator" with a let declaration for the variable i. Assign it the value 0 to start. This will give the i variable the value 0 the first time your loop runs.

--hints--

You should use let to declare an i variable.

js
assert.match(__helpers.removeJSComments(code), /let\s+i/);

You should assign 0 to your i variable.

js
assert.match(__helpers.removeJSComments(code), /let\s+i\s*=\s*0/);

Your for loop should start an i iterator at 0.

js
assert.match(__helpers.removeJSComments(code), /for\s*\(\s*let\s+i\s*=\s*0/);

--seed--

--seed-contents--

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

--fcc-editable-region--
for ("iterator"; "condition"; "iteration") {

}
--fcc-editable-region--