-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
72 lines (62 loc) · 1.44 KB
/
script.js
File metadata and controls
72 lines (62 loc) · 1.44 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
var resume = { //created resume in JSON format.
"fullName":"Manoj",
"email":"manojannadurai2265@gmail.com",
"phoneNumber":"9944112684",
"address":"palayamkottai , tirunelveli",
"summary":"junior web developer seeking for a job",
"education":"pg",
"skills":["html","css","js","nodejs"]
}
//using for loop
var keys=Object.keys(resume);
for(let i=0;i<keys.length;i++)
{
let key=keys[i];
let value=resume[key];
if(Array.isArray(value)){ //Array.isArray() is a built-in function
for(var a=0;a<value.length;a++){ // It checks the value is an array or not.
console.log(value[a]);
}
}
else{
console.log(value);
}
}
for(var i=0;i<resume.length;i++)
{
console.log(resume.key[i]);
}
//using for in loop
for(var key in resume){
if(Array.isArray(resume[key])){
for(var i=0;i<resume[key].length;i++){
console.log(resume[key][i]);
}
}
else{
console.log(resume[key]);
}
}
//using for of loop
var valarr=Object.values(resume) //converting object to array for using for of and for each loop
for(var value of valarr){
if(Array.isArray(value)){
for(var skill of value){
console.log(skill);
}
}
else{
console.log(value)
}
}
//using for each loop.
valarr.forEach(function(value){
if(Array.isArray(value)){
value.forEach(function(innerarr){
console.log(innerarr);
});
}
else{
console.log(value);
}
})