Step 33 Passed
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 loop. There are many ways to write a loop.
You are going to start with a basic for loop. for loops use the following syntax:
Example Code
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 body, the section within the curly braces {}, empty.
Not sure what step you’re on, bu it should get explained more as you go. This is just to show the framework of a for loop and it’s different parts.
iterator: the variable the for loop will follow (ex. let i = 0)
condition: defines the point the loop should stop (ex. i = 10)
iteration: how to increment the variable (ex. i++)
Maybe other examples and documentation will help.
here is my code:
for (let i = 0; i.length > 0; i++) {}
i
is a simple integer variable, it doesn’t have a length property
This loop will stop after one step, because when you add 1 to 0 it will be > 0.