Console log every even number

Console log every even number


What am I doing wrong? Instead of number I’m trying to print the even number foods


i only refers to the number you declared in the for loop.

Try logging foods with the i index, so


var foods = ["fries", "kebab", "pasta", "raviolli", "coke", "pizza"];

//change var i = 0 instead of 2 to start from the beginning (index 0).
for(var i = 0; i < foods.length; i+=2) { 
//change the (i) to foods[i] to capture the array.