-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path09.js
More file actions
97 lines (67 loc) · 1.6 KB
/
09.js
File metadata and controls
97 lines (67 loc) · 1.6 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
for (let i = 0; i <= 1; i++) {
console.log('Value of i = ',i)
} // Declair, Condition, increasement-decreasement
for (let i = 5; i > 0; i--){
console.log('Value of d. =', i)
}
for (let i = 5, j = 0; i >= 0, j <= 5; i--, j++ ){
console.log('i : ', i, 'j : ', j)
}
for (let i = 0; i <= 3; i++){
for(let j = 3; j >= 0; j--){
console.log('First : ', i, 'Second : ', j)
}
}
// practical example 01
let company = ['Cyber24BD', 'Samsung', 'Apple', 'MI', 'Hw']
// console.log(company[0])
// console.log(company[1])
// console.log(company[2])
for (let i = 0; i < company.length; i++){
console.log('Company name : ', company[i])
}
// practical example 02
let num01 = 125;
num01 = 1 + 2+ 3+4+5+6+7+8+9+10
console.log(num01)
let sum01 = 0;
for (let i = 0; i <= 10; i++){
sum01 += i
}
console.log('Sum of 10 is : ', sum01)
// for in
let author = {
name : 'Cyber24BD',
age : 4,
writer : 'Sakib',
}
console.log(author['name'])
for (key in author){
console.log('This is for in loop')
console.log(key, ':', author[key])
}
// for of
let companys = ['Cyber24BD', 'Samsung', 'Apple', 'MI', 'Hw']
for (com of companys){
console.log('For of : ', com)
}
// While loop = condition
// true and false
let wi = 0;
while ( wi < 5) {
console.log("I am while Loop", wi)
wi++
}
let pass;
// while(pass !== 'cyber') {
// pass = prompt('Enter Password ! : ')
// }
console.log("Access Granted")
// invalid
for (let i = 5; i < 0; i--){
console.log('Value of d. =', i)
}
// infinite
// for (let i = 0; i >= 1; i++) {
// console.log('Value of i = ',i)
// }