Prev Demo
JavaScript
>
How To Write While Loop In Javascript?
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>While Loop</h1> <script> function TestFunction() { var i = 0; while (i < 5) { alert(i); 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