The JavaScript while loop iterates the elements for the infinite number of times. It should be used if number of iteration is not known. The syntax of while loop is given below-
while (condition)
{
code to be executed
}
Below is the simple example of while-loop:
<!DOCTYPE html>
<html>
<body>
<script>
var i=10;
while (i>=1)
{
document.write(i + "<br/>");
i--;
}
</script>
</body>
</html>
0 Comment(s)