4/17. Code is accepted, but does not log anything to the console


#1

Hello,

Why does this not print anything to the console?

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

for (languages = 0; i = languages.length; languages++) {
console.log(languages);
};

Thank you


#2

We are already using languages to refer to a data array. We should not re-use the variable else our array gets overwritten.

for (languages = 0; i = languages.length; languages++) {
    console.log(languages);
};

Plus, we will want to print the languages out one at a time, so will refer to their respective index thru each iteration of the loop.

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

One final note, you will notice that we do not end a for statement with a semi-colon.