Basic JavaScript - Count Backwards With a For Loop

Tell us what’s happening:
Describe your issue in detail here.

I have tried console.log inside of loops and outside of loops. Still couldn’t come out 9,7,5,3,1. It only comes out without the 1

 **Your code so far**
// Setup
//initialization var i = 9
//condition i means 9 > 1
//final expression 9 subtract 2 on each loops

const myArray = [];
for (var i = 9; i > 1; i -= 2) {
myArray.push(i);

}
console.log(i)

// Only change code below this line

 **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Count Backwards With a For Loop

Link to the challenge:

Can you please add the values you get after you console.log the values in the for loop.

This what i’m getting after i did the console.log inside the loops
// running tests

myArray

should equal

[9, 7, 5, 3, 1]

. // tests completed // console output 9 7 5 3 9 7 5 3

Will this loop body execute when i===1?

Nope. It did not work with i===1

So how can you modify the loop condition so that it is still true when i===1

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.