Page 327 - Web Applications (803) Class 11
P. 327
Ð ÐLoop body: This section contains the statements that are to be executed repeatedly enclosed within the curly
braces.
Ensure that every expression should be terminated with a semicolon in the for loop, otherwise an error will occur.
Flow Diagram
Initialization/Starting
statement
Next iteration of the loop
Test True Execute
Statement statement(s)
False
Exit from loop
Example:
<HTML>
<BODY text="blue">
<H2> Using a for loop</H2>
<P style="color:red;">
<SCRIPT>
var p_name=prompt("Enter your name");
for (i = 0; i < 5; i++) {
document.write("Hello " +p_name+"<BR><BR>"); }
</SCRIPT></P>
</BODY>
</HTML>
Output:
Introduction to Dynamic Websites Using JavaScript 325

