forked from chinmay021/web-development-tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut55.html
More file actions
64 lines (52 loc) · 1.58 KB
/
tut55.html
File metadata and controls
64 lines (52 loc) · 1.58 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
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Loops</title>
</head>
<body>
<div class="container">
This is about loops
</div>
<script>
console.log("This is tutorial 55");
// let i = 0;
// for(i=0; i<3;i++){
// console.log(i);
// }
let friends = ["Rohan", "Sanjeev", "Deepti", "Pooja", "SkillF"];
// for (let index = 0; index < friends.length; index++) {
// console.log("Hello friend, " + friends[index]);
// }
// friends.forEach(function f(element){
// console.log("Hello Friend, " + element + " to modern JavaScript");
// });
// for (element of friends){
// console.log("Hello Friend, " + element + " to modern JavaScript again");
// }
let employee = {
name: "Harry",
salary: 2,
channel: "CWH"
}
// Use this loop to iterate over objects in JavaScript
for (key in employee) {
console.log(`The ${key} of employee is ${employee[key]}`);
}
// while loop in js
let i = 0;
while (i < 4) {
console.log(`${i} is less than 4`);
i++;
}
// do while loop in js
let j = 34;
do {
console.log(`${j} is less than 4 and we are inside do while loop`);
j++;
} while (j < 4);
</script>
</body>
</html>