Files

37 lines
509 B
Markdown
Raw Normal View History

2018-10-12 15:37:13 -04:00
---
title: Count Backwards With a For Loop
---
# Count Backwards With a For Loop
2018-10-12 15:37:13 -04:00
---
## Hints
2018-10-12 15:37:13 -04:00
### Hint 1
2018-10-12 15:37:13 -04:00
* create a new for loop for myArray
### Hint 2
2018-10-12 15:37:13 -04:00
* start from the first odd number just before 9
---
## Solutions
<details><summary>Solution 1 (Click to Show/Hide)</summary>
2018-10-12 15:37:13 -04:00
```javascript
var ourArray = [];
for (var i = 10; i > 0; i -= 2) {
ourArray.push(i);
}
// Setup
var myArray = [];
// Only change code below this line.
for (var i = 9; i > 0; i -= 2) {
myArray.push(i);
2018-10-12 15:37:13 -04:00
}
```
</details>