JS While Loop

The while loop loops through a block of code as long as a specified condition is true.

Syntax

while (condition) 
{
    // code block to be executed
}
<!DOCTYPE html>
<html>
<head>
    <title>JavaScript</title>
    <script>
        /*Increase While Loop Condition */
        var a = 1;

        while (a <= 10) {
            document.write(a + ") Hello Yahoo Baba <br>");
            a = a + 1;
        }

        /*  Decrease While Loop Condition */
        
        var x = 10;

        while (x >= 1) {
            document.write(x + ") Hello Yahoo Baba <br>");
            x = x - 1;
        }
    </script>
</head>
<body>
</body>
</html>