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

606 B

title
title
Iterate with JavaScript While Loops

Iterate with JavaScript While Loops


Problem Explanation

While loops will run as long as the condition inside the ( ) is true.

Example:

while (condition) {
  //code...
}

Hints

Hint 1

Use a iterator variable such as i in your condition

var i = 0;
while (i <= 4) {}

Solutions

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

// Only change code below this line.
var i = 0;
while (i <= 4) {
  myArray.push(i);
  i++;
}