Page 375 - Webapplication11_C11_Flipbook
P. 375
document.write(i +" => " + days[i]);
document.write("</br>");
}
document.write("</br>");
</SCRIPT>
</BODY>
</HTML>
On running the above program, we get the following output:
The while Loop
The while statement or loop is used to repeat a set of instructions until a conditional expression returns True. Once the
expression returns False, the loop is terminated. Following is the syntax of the while loop in JavaScript:
initialisation_expression;
while (conditional_expression) {
//loop body
update_expression;
}
Where,
Ð Ðinitialisation_expression: In this expression, a variable is initialized. Unlike for loop, this section appears outside
the loop.
Ð Ðconditional_expression: Similar to for loop, this expression contains a logical condition which evaluates either True
or False.
Ð Ðupdate_expression: The loop control variable is updated here.
Flow Diagram
Ini aliza on/Star ng
statement
Next itera on of the loop
Execute
Test True statement(s) inside
Condi on
body of loop
False
Exit from loop
JavaScript Part 1 373

