Edit This Code:
<!DOCTYPE html>
<html>
<body>

<p>In this example, we have omitted the last parameter, and incremented the counter variable inside the loop.</p>

<p>Click the button to loop through the indices of an array, in ascending order.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var cars = ["BMW", "Volvo", "Saab", "Ford"];

    var i = 0;
    var len = cars.length;
    var text = "";

    for (; i < len;) {
        text += cars[i] + "<br>";
        i++;
    }
    document.getElementById("demo").innerHTML = text;
}
</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy