{[['']]}
The JavaScript while loop is much simpler than the for loop. It consists of a condition and the statement block.
Syntax:
while (condition)
{
...statements...
}
Ex1:
<script>
var msg = "";
var x = 1;
while (x <= 10)
{
msg = msg + x + "\n";
x++;
}
alert(msg);</script>
Ex2:
<script>
var msg = "";
var x = 1;
var res = 0;
while (x <= 10)
{
res = 12 * x;
msg = msg + "12 X " + x + " = " + res + "\n";
x++;
}
alert(msg)
</script>
Output: n/a