June 2014
Intermediate to advanced
696 pages
38h 52m
English
You can iterate through an array by using a for or a for/in loop. The following code illustrates iterating through each item in the array using each method:
var week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"];for (var i=0; i<week.length; i++){ console.log("<li>" + week[i] + "</li>");}for (dayIndex in week){ console.log("<li>" + week[dayIndex] + "</li>");}
Read now
Unlock full access