-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
74 lines (55 loc) · 1.15 KB
/
app.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// FOR LOOP
// for(let i = 0; i < 10; i++){
// if(i === 2){
// console.log('2 is my favorite number');
// continue;
// }
// if(i === 5){
// console.log('Stop the loop');
// break;
// }
// console.log('Number '+ i);
// }
// WHILE LOOP
// let i = 0;
// while(i < 10){
// console.log('Number ' + i);
// i++;
// }
// DO WHILE
// let i = 100;
// do {
// console.log('Number ' + i);
// i++;
// }
// while(i < 10);
// LOOP THROUGH ARRAY
const cars = ['Ford', 'Chevy', 'Honda', 'Toyota'];
// for(let i = 0; i < cars.length; i++){
// console.log(cars[i]);
// }
// FOREACH
// cars.forEach(function(car, index, array){
// console.log(`${index} : ${car}`);
// console.log(array);
// });
// MAP
// const users = [
// {id: 1, name:'John'},
// {id: 2, name: 'Sara'},
// {id: 3, name: 'Karen'},
// {id: 4, name: 'Steve'}
// ];
// const ids = users.map(function(user){
// return user.id;
// });
// console.log(ids);
// FOR IN LOOP
const user = {
firstName: 'John',
lastName: 'Doe',
age: 40
}
for(let x in user){
console.log(`${x} : ${user[x]}`);
}