You should never use for/in
for iterating an array. And, when you were doing so, you were just getting the array indices, not the actual array elements.
for/in
iterates all enumerable properties of the object, not just array elements which can end up including things you do not want. See for ... in loop with string array outputs indices and For loop for HTMLCollection elements for details.
Instead, you can use any number of other options. The modern way is probably for/of
which works for any iterable (which includes an array).
for/of
let array = [1, 2, 3];
for (let a of array) {
console.log(a);
}
.forEach()
let array = [1, 2, 3];
array.forEach(function(a, index) {
console.log(a);
});
Plain for loop
let array = [1, 2, 3];
for (let i = 0; i < array.length; i++) {
console.log(array[i]);
}