basic for loop odd numbers

a basic for loop with odd numbers adding to an array

Javascript

var myArray = [];
for (var i = 1; i <= 9; i += 2) {
  myArray.push(i);
}
console.log(myArray);

Demo

Other Items in javascript
Page Views

This page has been viewed 61 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

❤👩‍💻🕹