-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject_challenge.js
More file actions
74 lines (65 loc) · 1.62 KB
/
object_challenge.js
File metadata and controls
74 lines (65 loc) · 1.62 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
70
71
72
73
74
var course = {
name: 'JavaScript Applications',
awesome: true,
teachers: ['Assaf', 'Shane'],
students: [
{
name: 'Steve',
computer: {
OS: 'Linux',
type: 'laptop'
}
},
{
name: 'Katy',
computer: {
OS: 'OSX',
type: 'macbook'
}
},
{
name: 'Chuck',
computer: {
OS: 'OSX',
type: 'macbook'
}
}
],
preReqs : {
skills : ['html', 'css', 'git'],
equipment: {
laptop: true,
OSOptions: ['linux', 'osx']
}
}
};
var tmp = null;
// Name of the course ('JavaScript Applications')
tmp = course.name
console.log(tmp);
// Name of the second teacher ('Shane')
tmp = course.teachers[1]
console.log(tmp);
// Name of the first student ('Steve')
tmp = course.students[0].name
console.log(tmp);
// Katy's computer type ('macbook')
tmp = course.students[1].computer.type
console.log(tmp);
// The preReq equipment object
tmp = course.preReqs.equipment
console.log(tmp);
// The second OSOption from equipment prereqs ('osx')
tmp = course.preReqs.equipment.OSOptions[1]
console.log(tmp);
// string listing the OSOptions separated by 'or' ('linux or osx')
tmp = course.preReqs.equipment.OSOptions.join(' or ')
console.log(tmp);
// An array of all the students that are using OSX.
osx_list = []
for (i = 0; i < course.students.length; i++) {
if (course.students[i].computer.OS === 'OSX'){
osx_list.push(course.students[i])
}
}
console.log(osx_list);