-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloops.html
More file actions
52 lines (45 loc) · 1.65 KB
/
loops.html
File metadata and controls
52 lines (45 loc) · 1.65 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Learning JavaScript</title>
</head>
<body>
<center><h1>The For Loop</h1></center>
<h3>If we want to print numbers such as 1 through ten. Yes we can type console.log(1) and retype it ten 10 time. However, we wan tto save data and avoid repetion of code.</h3>
<ol>
<li>For(initialize;test; increment/decrement<br/>
decrement) {// code Block//}</li>
<li>Eample standard For Loop</li>
<li>for(var i = 0; i < i; i++ {<br />
console.log(i);} // this will print the number from 1 thourgh 10.)</li>
<li>We use i, because that is short for index</li>
<center><right><img src="media/Screen%20Shot%202018-10-29%20at%209.16.13%20PM.png" height="400" width="500"></right></center>
</ol>
<center><h1>The While Loop</h1></center>
<p>The loop then performs some action, which affects that condition repeatedly until that condition becomes false.</p>
<center><img src="media/Screen%20Shot%202018-10-29%20at%209.36.25%20PM.png" height="400" width="500"></center>
<p>for (var i =0; i < 11; i++) { <br />
console.log(i);<br />
}<br />
<br />
var roopak = ['Roopak', 'kumar', 1990, 'student', true];<br />
for (var i = 0; i < roopak.length; i++) {<br />
console.log(roopak[i]);<br />
}<br />
<br />
<br />
//While Loop<br />
<br />
var i = 0;<br />
while(i < roopak.length) {<br />
console.log(roopak[i]);<br />
i++;<br />
}</p><br />
<form action="loops_result.html">
<input type="submit" name="Check" value="Check">
<p>click 'Check' to see the answer</p>
</form>
<script src="loops.js"></script>
</body>
</html>