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
MUZ141026 Bertha Ndachengedzwa
6,260 Pointswhats wrong with my code? please help. stuck for hours
You're going to modify the Teacher code to inherit from the Person. First, in the Teacher constructor function, call the Person constructor, using the call method and pass in the common attributes.
Bummer! You're missing Person.call in the Teacher construction function.
person.js
teacher.js
1
function Teacher(firstName, lastName, roomNumber) {
2
this.firstName = firstName;
3
this.lastName = lastName;
4
this.room = roomNumber;
5
}
6
ā
7
ā
8
function Teacher(firstName, lastName, roomNumber){
9
Person.call(this, firstName, lastName, roomNumber);
10
this.roomNumber = roomNumber;
11
}
2 Answers
Andrew Corcoran
20,552 PointsThe Person constructor does not accept a roomNumber argument. Just remove that from your Person.call() and it should pass.
function Teacher(firstName, lastName, roomNumber){
Person.call(this, firstName, lastName);
this.roomNumber = roomNumber;
}
MUZ141026 Bertha Ndachengedzwa
6,260 Pointsthanks, it worked
Lauren Scott
13,354 PointsLauren Scott
13,354 PointsHope this helps, not sure if it will makes sense being pasted on here like this.
function Teacher(firstName, lastName, roomNumber) { Person.call(this, firstName, lastName); this.room = roomNumber; }