-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject.js
More file actions
110 lines (84 loc) · 1.81 KB
/
object.js
File metadata and controls
110 lines (84 loc) · 1.81 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
var classrooms = [{
teacher: {
name: "John Keating",
subject: "Literature",
age: 57
},
students: [{
name: "John",
age: 32
},
{
name: "Suzy",
age: 29
},
{
name: "Jill",
age: 44
},
{
name: "Joe",
age: 20
}]
},{
teacher: {
name: "Lillian Beauregard",
subject: "Math",
age: 74
},
students: [{
name: "Johnny",
age: 14
},
{
name: "Suzie",
age: 18
},
{
name: "Jo",
age: 22
}]
},{
teacher: {
name: "Mr. Schmidt",
subject: "Literature",
age: 50
},
students: [{
name: "Bob",
age: 32
},
{
name: "George",
age: 46
}]
}];
// function studentsAvg() {
// return (classrooms[0].students[0].age + classrooms[0].students[1].age + classrooms[0].students[2].age + classrooms[0].students[3].age ) ;
// }
// function studentsAvg2() {
// return (classrooms[1].students[0].age + classrooms[1].students[1].age + classrooms[1].students[2].age) ;
// }
// function studentsAvg3() {
// return (classrooms[2].students[0].age + classrooms[2].students[1].age) ;
// }
// console.log((studentsAvg() + studentsAvg2() + studentsAvg3()) / 9);
// function teacherAvg() {
// return (classrooms[0].teacher.age)
// }
// function teacherAvg2() {
// return (classrooms[1].teacher.age)
// }
// function teacherAvg3() {
// return (classrooms[2].teacher.age)
// }
// console.log((teacherAvg() + teacherAvg2() + teacherAvg3()) / 3);
// function litAvg() {
// return (classrooms[0].students)
// }
// console.log(litAvg())
for(var i = 0; i < classrooms.length; i++){
for (var j = 0; j < classrooms[i].students.length; j++){
console.log(classrooms[i].students[j]);
}
}