Iterate through an array

Hi, having some issues solving this problem:

Iterate over the array provided in powerRangers and print to the console a string that shows the elements’ index and the content of the element.
e.g.: ‘0: Red’

var powerRangers = ['Red', 'Black', 'Yellow', 'Pink', 'Blue'];

for (var i = 0; i < powerRangers.lenght; i++) {
    console.log(i + ':' + powerRangers[i]);
}

The output says:

Code is incorrect
The for loop should iterate until i reaches the length of the array

Thanks !

I think it is typo error because you write

powerRangers.lenght

instead of

powerRangers.length
1 Like

Yesss! you were right! Shame on me!
Thank you so much!!

1 Like