Count Backwards With a For Loop 1

Tell us what’s happening:

I can’t run the test. Every time i run the test the browser goes down AND NOT RESPONDING

Your code so far


// Example
var ourArray = [];

for (var i = 10; i > 0; i -= 2) {
  ourArray.push(i);
}

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

// Only change code below this line.


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/count-backwards-with-a-for-loop

You have a typo here. => is not the greater than or equal to comparison operator.

1 Like

this made an infinite loop?

Basically that is what happened. The => is something special in JavaScript which you will learn about later in the ES6 section. You basically created a function with the i => 1. Functions have a truthy value in JavaScript, so your for loop condition was always true.

okay, got it, Thank you for your help.