Skip to content

Commit fddb7ac

Browse files
Stretch Goals completed
1 parent 0d73d42 commit fddb7ac

2 files changed

Lines changed: 29 additions & 11 deletions

File tree

‎assignments/arrays.js‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,4 @@ inventory.forEach(function(element){
115115
}
116116
index++;
117117
});
118-
console.log(JSON.stringify(BMWAndAudi));
119-
120-
121-
118+
console.log(JSON.stringify(BMWAndAudi));

‎assignments/objects.js‎

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const kennan = {
3030
"email": "kdiben1@tinypic.com",
3131
"gender": "M",
3232
speak(){
33-
return `"Hello, my name is ${kennan.name}!"`;
33+
return `Hello, my name is ${kennan.name}!`;
3434
},
3535
};
3636
const keven = {
@@ -85,16 +85,37 @@ console.log(antonietta.multiplyNums(3,4));
8585
// 3. Nest a grandchild object in the child object with properties for name and age. The name will be Sam and the age will be 30
8686
// 4. Give each of the objects the ability to speak their names using the this keyword.
8787

88-
const parent = {}
88+
const parent = {
89+
name: "Susan",
90+
age: 70,
91+
speak() {
92+
console.log(`Hello, my name is ${this.name}`);
93+
},
94+
child: {
95+
name: "George",
96+
age: 50,
97+
speak() {
98+
console.log(`Hello, my name is ${this.name}`);
99+
},
100+
grandchild: {
101+
name: "Sam",
102+
age: 30,
103+
speak() {
104+
console.log(`Hello, my name is ${this.name}`);
105+
},
106+
}
107+
}
108+
};
89109

90110
// Log the parent object's name
91-
111+
console.log(parent.name);
92112
// Log the child's age
93-
113+
console.log(parent.child.age);
94114
// Log the name and age of the grandchild
95-
115+
console.log(`${parent.child.grandchild.name} ${parent.child.grandchild.age}`);
96116
// Have the parent speak
97-
117+
parent.speak();
98118
// Have the child speak
99-
119+
parent.child.speak();
100120
// Have the grandchild speak
121+
parent.child.grandchild.speak();

0 commit comments

Comments
 (0)