Prev Demo
JavaScript
>
How To Write For Loop In Javascript?
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>For Loop</h1> <script> function TestFunction() { var i = 5; for (i = 0; i < 5; i++) { alert(i); } } </script> <input type="button" id="btnTest" onclick="TestFunction()" value="Click me" /> </body> </html>
Note: We DO NOT save your trial code in our database.
Output