+ 1

Why it is not possible to call the getName method of the assigned Person object from the Citizen class?

https://code.sololearn.com/WXxWG411R40p/?ref=app

14th Oct 2018, 8:24 PM
Mirko Klotzsche
Mirko Klotzsche - avatar
4 Respuestas
14th Oct 2018, 8:53 PM
Burey
Burey - avatar
+ 4
Your Citizen constructor should be: this._obj = person_object; Also in the Person constructor, when declaring as "var _age = age;" you will not have access to that variable inside the class methods. it should be this._age = age; and same for name, no need to declare var for it inside the condtructor
14th Oct 2018, 8:36 PM
Burey
Burey - avatar
+ 4
The answers in that post that I was going to suggest are: https://stackoverflow.com/a/28165599 https://stackoverflow.com/a/22509411
14th Oct 2018, 9:06 PM
David Carroll
David Carroll - avatar
0
I am a little bit in trouble with JS ... That works but it makes all the properties public.
14th Oct 2018, 8:42 PM
Mirko Klotzsche
Mirko Klotzsche - avatar