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 trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Mohammed Ali](https://secure.gravatar.com/avatar/062bc3709913925e1e29c9ff2eb8da8a?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Mohammed Ali
10,625 PointsHi, I'm stuck on Object-Oriented JavaScript, Setting up the Prototype Chain. Can someone give a hand please?
In teacher.js -
Solution: Person.call(this, firstName, lastName); Error message: Bummer! You don't need to set the firstName or lastName properties, the Person.call will handle that!
Solution: Person.call(this);
Error: Bummer! The Person.call
method needs this
, firstName
and lastName
, in that order!
Any advice would be super useful. Thanks
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.firstName = firstName;
this.lastName = lastName;
this.room = roomNumber;
}
2 Answers
![Raja Kannan](https://secure.gravatar.com/avatar/96b65ce8434f89b752e1aea66b548ca5?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Raja Kannan
6,590 PointsHi Mohammed Ali, You are almost correct. You had inherited the code form Person. So no need to repeat firstname and lastname after Person.call method. Because these two properties are defined in Person which we are inheriting.
this.firstName = firstName;
this.lastName = lastName;
try the code below:
function Teacher(firstName, lastName, roomNumber) {
Person.call(this,firstName, lastName);
this.room = roomNumber;
}
![Zoltán Levente Papp](https://secure.gravatar.com/avatar/541a2760ecfd38d8770884af820ba2ba?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Zoltán Levente Papp
3,045 PointsThis is not an answer rather a question. The challenge has a Step 2. This is my solution:
function Teacher(firstName, lastName, roomNumber) { Person.call(this, firstName, lastName); this.room = roomNumber; } Teacher.prototype = Object.create(Person.prototye);
For some reason I receive this msg again and again:
Bummer! You have an assignment but not Teacher.prototype = Object.create();
with the Person
's prototype.
??? pls help
Mohammed Ali
10,625 PointsMohammed Ali
10,625 PointsThat worked, thanks Raja