Stuck on lesson "Arrays and Objects in JS"


so the prompt of the computer is saying to individually print out of the elements of the array made in this exercise; I have been printing the variable ("languages") and so the whole array is printed.
I just cant think for the life of me how to print each one out individually, ayuda me

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


The trick is in using your i variable. You want to access each array element individually by an address/index.


Your code has it logging the full array for as long as value 'i' is less than the length of the array (5, this case). Meaning, it'll log all 5 elements 5 times.

Instead, you can log each element by calling for the specific element in the array (ex. languages[0], languages[1], etc).

You just need to change the console.log code to "console.log(languages[i])" so it only logs one element at a time. Hope that was thorough!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.