odd numbers in for loop code example
Example: Iterate Odd Numbers With a For Loop
var myArray = [];
for (var i = 1; i < 10; i += 2){
myArray.push(i);
}
console.log(myArray); // console output [ 1, 3, 5, 7, 9 ]
var myArray = [];
for (var i = 1; i < 10; i += 2){
myArray.push(i);
}
console.log(myArray); // console output [ 1, 3, 5, 7, 9 ]