Javascript examples for Statement:while
while Loop backwards through the indices of an array
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {// ww w. java2 s. c o m var cars = ["a","b","c","d","e"]; var text = ""; var len = cars.length; while (len--) { text += cars[len] + "<br>"; } document.getElementById("demo").innerHTML = text; } </script> </body> </html>