forked from rohan-paul/Awesome-JavaScript-Interviews
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnested-objects-prob-2.js
44 lines (38 loc) · 1013 Bytes
/
nested-objects-prob-2.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
const userInfo = {
firstName: 'Avi',
lastName: 'Flombaum',
company: {
name: 'Flatbook Labs',
jobTitle: 'Developer Apprentice'
},
friends: [{
firstName: 'Joe',
lastName: 'Burgess',
company: {
name: 'Flatbook Labs',
jobTitle: 'Developer Apprentice'
}
},
{
firstName: 'Gabe',
lastName: 'Jackson',
company: {
name: 'Flatbook Labs',
jobTitle: 'Lead Developer'
}
}],
projects: [{
title: 'Flatbook',
description: 'The premier Flatiron School-based social network in the world.'
},
{
title: 'Scuber',
description: 'A burgeoning startup helping busy parents transport their children to and from all of their activities on scooters.'
}]
};
// Whats the first name of his first friend:
const a = userInfo.friends[0].firstName;
console.log(a); // => Joe
// Whats the title of his second project:
const b = userInfo.projects[1].title;
console.log(b);