Could we help you? Please click the banners. We are young and desperately need the money
A loop is an action that allows a certain part of a code to be repeated while some condition evaluates to true.
First you have to define a Variable with an array as the value:
const food = ['Burger', 'Fries', 'Pizza'];
Now you have to create your for() loop with:
for () {}
for (statement 1; statement 2; statement 3) { //this is the codeblock }
Statement one is executed (once) before the for loop's first run.
Statement two must be fulfilled for the loop to be executed. It's essentially the loop's condition.
Statement three is always executed after each run of the loop.
for (let i = 0; i < food.length; i++) { };
In the first statement we create a variable named "i" (for index).
In the second statement we specify a condition, setting the requirement for the loop to be run to "i" having to be smaller than food.length.
In the third statement, we say that "i" should be incremented after each loop.
In JavaScript you can log something into your console with "console.log()".
So, we will use it to log our loop into the console. This is the final result:
for(let i = 0; i < Food.length; i++) { console.log(food[i]); }
Now you should be ready to go and see it in your console.