Basic javaScript: Iterate Odd number isn't working

I will not test me and I can’t progress. none of the buttons are working either.

I’ve restart my computer, run norton, turn off everything, used internet explorer, used chrome incognito,and I’m about to use foxfire???sp. its not working at all. but is is working in other test.

Responed to your post in General which was moved to Javascript.
Asked to see the code you’ve tried and gave a possible reason you may be stuck.
Waiting your response. (It’s hard to give an intelligent/helpful answer when those replying don’t know what you’ve done.)
Don’t know what “its not working at all. but is is working in other test.” actually means. Something isn’t working but is working??

Edit: This question was originally asked in General and then moved to Javascript ( Basic javascript: iterated odd numbers stop working ) since the lesson you’re stuck on appears to be a JS lesson. I’ve responded to that original post too.

Not working in Firefox either.

9

10

11

12

13

14

15

// Example

var ourArray = [];

 

for (var i = 0; i < 10; i += 2) {

  ourArray.push(i);

}

 

// Setup

var myArray = [];

 

// Only change code below this line.

for(var i = 0; i < 10; i + 2) {

  myArray.push(i);

} 
  • You want to be pushing odd numbers, not even. The first time through your loop you’re pushing 0 but you want it to be 1.
  • Watch how you increment. The sample code correctly shows you i += 2

yea i saw the 0ne and fix it but if i’m going to get odd numbers i will have to add 2.
1+2 = 3
3+2 = 5 .etc
I also change i <= 9

Correct, you have to increment by two but your code is showing i + 2 instead of i += 2
You can leave it at i < 10 too. Both will work.

I don’t want it to equal 2. 2 is even.

i += 2 is not setting it to two. If i starts as 1 and you add 2 to it, that equals 3

1 Like

that worked I hate math.

1 Like