-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday03_loops.js
57 lines (50 loc) · 1011 Bytes
/
day03_loops.js
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
// LOOPS
// 1) FOR LOOP
console.log("FOR LOOP")
for(let i=0; i <= 5; i++){
console.log(i)
}
// 2) FOR OF LOOP
console.log("FOR OF LOOP")
const iterable = [0, 1, 2, 3, 4, 5]
for ( let a of iterable) {
console.log(a)
}
const todo = [
{
id: 1,
task: "meeting",
isComplate: true
},
{
id: 2,
task: "shopping",
isComplate: true
},
{
id: 3,
task: "doctor",
isComplate: true
},
]
console.log("Writing with for loop")
for(let i=0; i < todo.length; i++){
console.log(todo[i])
}
for(let i=0; i < todo.length; i++){
console.log(todo[i].id)
console.log(todo[i].task)
console.log(todo[i].isComplate)
}
console.log("Writing with for of loop")
for ( let a of todo) {
console.log(a)
}
// 3) FOR EACH LOOP
const myArray = [1, 2, 3, 4]
myArray.forEach(function(eachItem){
console.log(eachItem)
})
// arrow
console.log("Arrow kullanarak ")
myArray.forEach(eachItem => console.log(eachItem))