Skip to content

Latest commit

 

History

History
48 lines (34 loc) · 523 Bytes

File metadata and controls

48 lines (34 loc) · 523 Bytes

While

Guides



Do loop based on length of array

var cars = ["BMW", "Volvo", "Saab", "Ford"];
var i = 0;
var text = "";

while (cars[i]) {
  text += cars[i] + "<br>";
  i++;
}
console.log('text: ' + text);



do/while statement

Syntax:

do {
  code block to be executed
}
while (condition);



var text = "";
var i = 0;
do {
  text += "The number is " + i;
  i++;
}
while (i < 5);