Let's say you have a simple array, for example
var someArray = ["1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9"];
Quoting through an array like this
for (var i = 0; i < someArray.length; i++) {
console.log(someArray[i]);
};
gives it in the console ......
1,2,3,4,5,6,7,8,9
.... but is there a way to iterate through an array to select only the nth elements? For example, the 3rd value would be provided in the console
1, 4, 7, ........
source
share