w3 for loop javascript code example
Example 1: for loop javascript
var i;
for (i = 0; i < 10 ; i++) {
//do something
}
Example 2: how to make a javascript for loop
var tops = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144];
for (let i = 0; i < tops.length; i++) {
document.write(tops[i] + "tops");
}
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