
Here is how to loop through arrays and array-like objects using JavaScript.
var sandwiches = [
'tuna',
'ham',
'turkey',
'pb&j'
];
for (var i = 0; i < sandwiches.length; i++) {
console.log(i) // index
console.log(sandwiches[i]) // value
}
// returns 0, tuna, 1, ham, 2, turkey, 3, pb&j