Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAndrew Chung
5,203 PointsNow set up the prototype chain for the Teacher prototype to inherit from the Person prototype.
So I really have no idea what to do here. Can anyone show me what the challenge wants me to do?
function Person(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
Person.prototype.fullName = function() {
return this.firstName + " " + this.lastName;
};
function Teacher(firstName, lastName, roomNumber) {
Person.call(this, firstName, lastName);
this.room = roomNumber;
}
3 Answers
geoffrey
28,736 PointsIn fact, you just need to recall what Andrew shows earlier in the course. So, If you want a class to inherit the methods from another class, you need to use Object.create(), in this case, this way:
Teacher.prototype = Object.create(Person.prototype);
Jeremy Barbe
8,728 PointsMe too Andrew....I don't know if it's me or the presentation of the material, but the entire prototype section of OOjs seems so convoluted.
john larson
16,594 PointsI'm starting to think Andrew got the hardest courses to teach. Apparently there's no simple way to learn this stuff.
It's a lot to keep track of. Referring back and forth to different codes and objects, learning DRY...I keep looking at all the different comments, I guess the idea is just keep at it till it starts to make sense. I know some people just get it, I'm happy for them. The rest of us just need to persevere.
gagan singh
Full Stack JavaScript Techdegree Student 12,889 Pointsthis is taking me a while took me like 10 mins beacuse i kept putting the code in wrong place i was putting inside the function ...lol
Andrew Chung
5,203 PointsAndrew Chung
5,203 PointsThanks, I've had the hardest time learning the material in this course.