# I'm stuck ? Iterate with JavaScript While Loops

**URL:** <https://forum.freecodecamp.org/t/im-stuck-iterate-with-javascript-while-loops/338298>\
**Category:** General\
**Created:** [January 4, 2020, 11:06am UTC](https://forum.freecodecamp.org/t/im-stuck-iterate-with-javascript-while-loops/338298 "2020-01-04T11:06:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chasle](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/chasle/32/127513_2.png) [@chasle](https://forum.freecodecamp.org/u/chasle)\
**Post date:** [January 4, 2020, 11:06am UTC](https://forum.freecodecamp.org/t/im-stuck-iterate-with-javascript-while-loops/338298/1 "2020-01-04T11:06:13Z")

</div>

via the iteration with javaScript while loops  
THE QUESTION AS FOLLOW  
Add the numbers 5 through 0 (inclusive) in descending order to `myArray` using a `while` loop.

Run the TestsReset All Code

Get Help

You should be using a `while` loop for this.

`myArray` should equal `[5,4,3,2,1,0]` .

AND MY CODE LOOK LIKE:

```auto
var myArray = [];
var i = 0;
while (i < 5) {
    myArray.push(i);
    i++;
}
console.log(myArray);

```

and when i press enter key automatically the whole web page went offline 🤔

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 4, 2020, 11:09am UTC](https://forum.freecodecamp.org/t/im-stuck-iterate-with-javascript-while-loops/338298/2 "2020-01-04T11:09:01Z")

</div>

It shouldn’t have an issue with an infinite loop  
but try the code line by line on paper, write down the value of each thing after each line, to see exactly what’s going on and what’s the result

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [June 1, 2021, 7:38pm UTC](https://forum.freecodecamp.org/t/im-stuck-iterate-with-javascript-while-loops/338298/3 "2021-06-01T19:38:34Z")

</div>


