Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ while(i < 5) {
i++;
}
```
In the code example above, the `while` loop will execute 5 times and append the numbers 0 through 4 to `ourArray`.


Let's try getting a while loop to work by pushing values to an array.

## Instructions
- Push the numbers 0 through 4 to `myArray` using a `while loop`.
- Add the numbers 5 through 0 (inclusive) in descending order to `myArray` using a `while` loop.

### Before

Expand All @@ -33,13 +35,16 @@ var myArray = [];

```javascript
// Setup
var myArray = [];
var i = 0 ;
while (i < 5) {
const myArray = [];

// Only change code below this line
let i = 0;

while (i < 6) {
myArray.push(i);
i++;
}

// Only change code below this line.
myArray.reverse(myArray);
console.log(myArray);
```