Why wont this work with an array


3 And the Good

I know I don't need to use an array to get this problem to work but I wanted to try just to get more practice with arrays. so why will my array elements not print out? Did I do something wrong or is it because an array is not mean to be used on this problem.

var numbers = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];

for(var i = 0, i < numbers.length , i++){


lets look at the error message:

SyntaxError: missing after for-loop initializer

not very helpful, but there is some useful info in there: after for loop initializer. lets look at the for loop initializer:

var i = 0,

a , after the for loop initializer, are you sure that is the right character/symbol/syntax? same for the for loop condition


Actually loops are iterable you just made the mistake of using commas instead of semi colons to divide your loop sections,

should be,

for(var i = 0; i < numbers.length; i++){ //Note the semi colons


awesome thank you I will get this down sooner or later.


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