Page 331 - Web Applications (803) Class 11
P. 331
Example:
<HTML>
<BODY>
for..in loop statement
</BR>
<script type = "text/javascript">
var days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday'];
for(const i in days){
document.write(i +" => " + days[i]);
document.write("</br>");
}
document.write("</br>");
</SCRIPT>
</BODY>
</HTML>
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.
Introduction to Dynamic Websites Using JavaScript 329

