-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlecture17.html
62 lines (57 loc) · 3.07 KB
/
lecture17.html
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
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lecture 17 | Loops in JS | For-loop in javascript |</title>
</head>
<body>
*****************************Tutorial Start 🔥 ********************************
<h1>Loops in JS | For-loop in javascript </h1>
<h4>What is Loops?</h4>
<P>Loops are used to execute the same block of code again and again, so long as a certain condition is met.</P>
<p>The basic idea behind the loop is to automate the repititive tasks within a program to save the time and effort.
Javascript now support five different types of loops:</p>
<li>for..loop</li>
<li>while</li>
<li>do..while</li>
<li>for..in loop(ye loop object ke property ko traverse karna ke liye use hota hai. ye related hai object se)</li>
<li>for..of(ye basically travel object ko retrieve karta hai. Repeat karne wale elements ko ye retrieve kar deta hai,
example: strings(ye strings ko traverse kar dega, aik aik karke characters nikaal dega.), array(array ko elements ko retreive karke nikaal dega)
jo retreivable hoge usko ye retrieve kar dega. jisme hum aik aik elements, characters nikaal sakte hai.
)</li>
<h4>For Loop</h4>
<p>Repeat the statement as long as certain conditions met.</p>
<li>jaisi voo condition true hogi, loop band hojayega.</li>
<script>
//structure of for loop
for(initialization; condition; increment) {
/* initialization--> ye voo variable hai jo track karega loop ko. Basically hamara loop hai kaha.
initialization--> ye basically variable hoga.
initialization--> isko hum skip bhi kar sakte hai.
*/
/* consition--> condition matlab true yaa false, jaise condition false hoga ye loop band hojayega.
And condition true hai too body execute ho jayegi. */
/* incrememet, decrement ka matlab steps hota hai, ki hum kitna steps follow kar rhe hai , 1 , 1 karke ke aagye
jaa rhe hai, 2 2 kar ke aagye jaa rhe hai , ki 1 , 1 karke ke piche aa rhe hai , yaa 12 12 karke ke aagye bar rhe hai.
*/
//code executed here
}
</script>
<p>
initialization ---> start
condition ---> end (humko yaha aisaa set karna hoga ki condition meri false ho jaaye)
increment ---> steps
</p>
<p>Flow of loop
1. First-> initialization
2. Second-> condition
3. Third-> body execution (code to be executed here)
4. Fourth-> increment
</p>
<p>Initialization sirf first time pe hoga., dusri baar se (condition, execution, increment/decrement)</p>
<script src="lecture17.js"></script>
***************************** Tutorial End 🚀 ********************************
</body>
</html>