Question 11, could be better
There are a few things I noticed.
- Typo in the description:
lydia.getFullName()should bemember.getFullName() - I'm not sure what do you mean under
would have made lydia.getFullName() work, but I think it still doesn't do what you expect because of Question 3. The arrow function executes not in the member context and you won't see the full name. In the same timePerson.prototype.getFullName = function() { return this.firstName + ' ' + this.lastName }should work as expected.
I'm not sure what do you mean under
would have made member.getFullName() work
I guess she means: would have returned "Lydia Hallie"
Thank you so much for bringing this up! This is a great point that I unfortunately totally missed. I have updated the question and the explanation of the question. 👍
@lydiahallie Hello, and thank you for this amazing job!
Regardless this question... I think that the answer to that still can be improved.
You can't add properties to a constructor like you can with regular objects. But we can. We can add any properties on function object, including functions that became a static methods.
If you want to add a feature to all objects at once, you have to use the prototype instead. If the goal is to show how you can add shared functionality that any instances can use, I think there is a need to add few more sentences to make it clear: shared functionality go to
.prototypeand static functionality go to the constuctor function itself.