Files
Randell Dawson 1494a50123 fix(guide): restructure curriculum guide articles (#36501)
* fix: restructure certifications guide articles
* fix: added 3 dashes line before prob expl
* fix: added 3 dashes line before hints
* fix: added 3 dashes line before solutions
2019-07-24 13:29:27 +05:30

819 B

title
title
Iterate Odd Numbers With a For Loop

Iterate Odd Numbers With a For Loop


Hints

Hint 1

After string // Only change code below this line. we add for loop. You need to copy loop from the top:

for (var i = 0; i < 10; i += 2) {
  ourArray.push(i);
}

Hint 2

And change initialization var i = 0 to var i = 1, also you need change name of the array ourArray to myArray:

for (var i = 1; i < 10; i += 2) {
  myArray.push(i);
}

Solutions

Solution 1 (Click to Show/Hide)
var ourArray = [];

for (var i = 0; i < 10; i += 2) {
  ourArray.push(i);
}

// Setup
var myArray = [];

// Only change code below this line.

for (var i = 1; i < 10; i += 2) {
  myArray.push(i);
}