-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloops.js
More file actions
52 lines (43 loc) · 870 Bytes
/
loops.js
File metadata and controls
52 lines (43 loc) · 870 Bytes
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
// General Loops: for, while, do-while
// let a =34;
// a +=1;
// a++;
// console.log(a);
// for(let i=0; i<100;i++){
// console.log(i);
// }
// let j = 110;
// while (j < 10) {
// console.log(j + 1);
// j += 1;
// }
// let k = 0;
// do {
// if(k===5){
// k +=1;
// continue;
// }
// console.log(k + 1);
// k +=1;
// } while (k < 10);
let arr = [2,5,6,4,2,3];
// for (let i = 0; i < arr.length; i++) {
// const element = arr[i];
// console.log(element)
// }
arr.forEach(function(element, index, array){
console.log(element, index, array);
});
arr.forEach(function(element){
console.log(element);
});
let obj = {
name: "Rohan Das",
age: 78,
type: "Dangerous Programmer",
os: "Ubuntu"
}
for(let key in obj){
console.log(`The ${key} of object is ${obj[key]}`)
}
console.log('done');