js do loop code example

Example 1: javascript for loop

for (var i; i < 10; i++) {
  
}

Example 2: do while javascript

do {
  //whatever
} while (conditional);

Example 3: for in loop javascript

var person = {"name":"taylor","age":31};
for (property in person) {
	console.log(property,person[property]);
}
//name taylor
//age 31

Example 4: do while loop in javascript

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

Example 5: js for loops

let i;
for (i = 0; i < 6; ++i) {
    console.log("Hello"); // print Hello 6 times
}

Example 6: javascript for in loop

const p = {
    "p1": "value1",
    "p2": "value2",
    "p3": "value3"
};

for (let [key, value] of Object.entries(p)) {
  console.log(`${key}: ${value}`);
}

Tags:

Java Example