JavaScript while loop

Notes:

JavaScript while loop: Entry control loop

Browser executes the statement(s) inside the while loop, until the given conditional expression evaluates to false.

Syntax:
initialization;
while(conditional expression)
{
statement(s);
increment/decrement;
}

Ex:
var i=1;
while(i<=5)
{
document.write(“Hello World <br/>”);
i++;
}

Note: When you don’t know exactly how many # of times the loop is going to get execute, use while loop.

Interview Questions: