-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuestion1.js
49 lines (35 loc) · 882 Bytes
/
Question1.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
let myData = {
"name": "Karthik T R",
"email": "karthiktr27597@gmail.com",
"phone": 8124199578,
"degree": "Bsc(CS),MBA",
"location": "Tamilnadu,Madurai"
}
let a= Object.keys(myData);
// for loop
for(let i=0; i>=0; i++)
{
if(a[i])
{
console.log(`${a[i]} : ${myData[a[i]]}`);
}
else
{
break;
}
}
console.log('-----------------------------------------------------------------');
//for in
for (let i in myData)
{
console.log(i+" : "+myData[i]);
}
console.log('-----------------------------------------------------------------');
// for of
for (let i of a) {
console.log(i+" : "+myData[i]);
}
console.log('-----------------------------------------------------------------');
// forEach
a.forEach(b =>{console.log(`${b} : ${myData[b]}`)})
console.log('-----------------------------------------------------------------');