Basic javaScript: Iterate Odd number isn't working

Basic javaScript: Iterate Odd number isn't working
0
#1

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

Basic javascript: iterated odd numbers stop working
#2

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.

#3

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.

#4

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);

} 
#5
  • 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
#6

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

#7

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.

#8

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

#9

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

1 Like
#10

that worked I hate math.

1 Like