The while loop loops through a block of code as long as a specified condition is true.
Syntax
while (condition) {
code block to be executed
}
The do/while loop is a variant of the while loop. This loop will execute the code block once, before checking if the condition is true, then it will repeat the loop as long as the condition is true.
Syntax
do {
code block to be executed
}
while (condition);
The for loop is often the tool you will use when you want to create a loop.
The for loop has the following syntax:
for (statement 1; statement 2; statement 3) {
code block to be executed
}
The JavaScript for/in statement loops through the properties of an object:
var person = {fname:"John", lname:"Doe", age:25};
var text = "";
var x;
for (x in person) {
text += person[x];
}
Javascript Loops
Let's Use Logics Into The Page