4/17 iterating over an array


#1

I have no clue what's wrong.
Here's the code:
var languages = ["HTML", "CSS", "JavaScript", "Python", "Ruby"];
for (var i = 0; i < languages.length; i++) {
console.log(languages)
}

The error is:
Oops, try again. It looks like you didn't log 'HTML' to the console!


#2

You want to print items in the array that are from languages[0] to languages[4] (you have 5 items and the first position of an array is 0). Try fixing your for loop to iterate through the correct numbers and print

Use
console.log(languages[i]);

The way it is now it's just printing entireentire list without looping through


#3

I had an issue where I was getting the same error even though I used console.log(languages[i]). I was able to resolve the issue by stripping the creative spin I put on my lesson but I thought it might be worth noting for future support cases.


#4

Kudos on going the extra mile and putting "I would like to learn " + languages[x] + " next!" but that's why it's coming up wrong. Codecademy isn't reading that you logged HTML because it's reading the beginning of the string whiich is "I would like to". If you take that out it should come up fine.


#5

After some fiddling, this worked:

var languages = ["HTML", "CSS", "JavaScript", "Python", "Ruby"];

for (var i = 0; i < languages.length; i++){
console.log(languages[i]);
}


#6

var languages = ["HTML", "CSS", "JavaScript", "Python", "Ruby"];
for (i = 0; i < languages.length; i++) {
console.log(languages[i]);
}


#7

console.log(languages[I])