@@ -32,7 +32,7 @@ const student2 = {
3232 "email" : "kdiben1@tinypic.com" ,
3333 "gender" : "M" ,
3434 "speak" : function ( ) {
35- return "Hello, my name is Kennan!"
35+ return "Hello, my name is Kennan!" ;
3636 }
3737}
3838
@@ -56,7 +56,7 @@ const student5 = {
5656 "email" : "adaine5@samsung.com" ,
5757 "gender" : "F" ,
5858 "multiplyNums" : function ( num1 , num2 ) {
59- return num1 * num2
59+ return num1 * num2 ;
6060 }
6161}
6262
@@ -103,16 +103,48 @@ console.log(student5.multiplyNums(3,4));
103103// 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
104104// 4. Give each of the objects the ability to speak their names using the this keyword.
105105
106- const parent = { }
106+ const parent = {
107+ name : "Susan" ,
108+ age : 70 ,
109+ speak : function ( ) {
110+ return "My name is " + this . name + "." ;
111+ } ,
112+ child : {
113+ name : "George" ,
114+ age : 50 ,
115+ speak : function ( ) {
116+ return "My name is " + this . name + "." ;
117+ } ,
118+ grandchild : {
119+ name : "Sam" ,
120+ age : 30 ,
121+ speak : function ( ) {
122+ return "My name is " + this . name + "." ;
123+ }
124+ }
125+ }
126+ }
107127
108128// Log the parent object's name
109129
130+ console . log ( parent . name ) ;
131+
110132// Log the child's age
111133
134+ console . log ( parent . child . name ) ;
135+
112136// Log the name and age of the grandchild
113137
138+ console . log ( parent . child . grandchild . name ) ;
139+
114140// Have the parent speak
115141
142+ console . log ( parent . speak ( ) ) ;
143+
116144// Have the child speak
117145
146+ console . log ( parent . child . speak ( ) ) ;
147+
118148// Have the grandchild speak
149+
150+ console . log ( parent . child . grandchild . speak ( ) ) ;
0 commit comments