Arrays and Objects in JS


#1


I made an array with 3 elements as asked, but I get a syntax error, and I am not sure what it is. I kept the code the same, just added an array.


var list = [1,2,3];

for(val i=1; val<51; val++1);
{
console.log(i);
}


#2

Your for loop should be

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

This will iterate over every item in your list and print it.
(Unless i am misunderstanding what your goal is)


#3

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