Javascript examples for Statement:Quiz
for loop: Set the counter variable (i) to 0, Run the loop as long as i is less than the length of the food array.
<!DOCTYPE html> <html> <body> <p id="demo"></p> <script> var text = ""; var food = ["yes", "B", "T", "F", "C"]; var i;/*w ww . j a v a 2 s. c o m*/ for (i = 0; i < food.length; i++) { text += "I love " + food[i] + "<br>"; } document.getElementById("demo").innerHTML = text; </script> </body> </html>