-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhiledemo.html
More file actions
35 lines (33 loc) · 993 Bytes
/
Copy pathwhiledemo.html
File metadata and controls
35 lines (33 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>javascript while loop</title>
</head>
<body>
<h1>Looping</h1>
<p>
a set of statemeents executing repeatedly, until a perticular condition is TRUE is called looping. if we want to perform certain taskes
again and again we should use loop
</p>
<p> A Loop should be :</p>
<ul>
<li>Intialized</li>
<li>Set a Condition</li>
<li>Increament / Decreament</li>
</ul>
<script>
var i = 0; // Loop initialization
while(i <= 10) { // set condition -> How many times Loop should execute
document.write("<p>The number is " + i + " Neeraj"+"</p>");
i++; // Increament Loop
}
document.writeln("<br><hr><br>");
var j = 10; // reverse Loop
while(j >= 1) {
document.write("<p>The number is " + j + " Neeru"+"</p>");
j--; // decreament the Loop
}
</script>
</body>
</html>