Javascript examples for Statement:Quiz
Use the break statement to stop the loop at 5.
<!DOCTYPE html> <html> <body> <p id="demo"></p> <script> var text = ""; var i;/*from w w w .j av a 2 s. c o m*/ for (i = 1; i < 10; i++) { if (i === 5) break; document.getElementById("demo").innerHTML += i + "<br>"; } </script> </body> </html>