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 Pointsam lost, please help
Challenge Task 1 of 2
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
Person.call = (this. firstName, lastName, roomNumber);
6
7
8
}
5 Answers
Erwin Meesters
15,088 PointsTeacher inherits the attributes from Person by calling the Person constructor: Person.call(this, firstName, lastName); So the firstName and lastName attributes are passed into the Teacher constructor that way. After that you need to add the "Teacher specific" attributes, in this case the roomNumber: this.room = roomNumber;
function Teacher(firstName, lastName, roomNumber) {
Person.call(this, firstName, lastName);
this.room = roomNumber;
}
Ken Wilson
7,885 PointsNone of these answers are correct. They do not pass
MUZ141026 Bertha Ndachengedzwa
6,260 Pointsit worked. thanx
Adrian Przybyła
Full Stack JavaScript Techdegree Student 7,260 Pointsteacher.js => function Teacher(firstName, lastName, roomNumber) { Person.call(this, firstName, lastName);
this.room = roomNumber; }
person.js => function Person(firstName, lastName) { this.firstName = firstName; this.lastName = lastName; }
Person.prototype.fullName = function() { return this.firstName + " " + this.lastName; };
Unsubscribed User
6,122 Pointsplease, whats the answer? I'm desperate for it. the video is not quit helping.
Rafael silva
23,877 Pointshey friend I will show for you a solution like this , in this chanllenge you have the first folder or document , and if you looking for has the teacher.js you need type, inside of Teacher.js like this:
function Teacher(firstName, lastName, roomNumber) {
Person.call(this,firstName,lastName);
this.room = roomNumber;
}
Kennedy Chimwanda
10,237 PointsKennedy Chimwanda
10,237 PointsNavigate to the Teacher.js and the code below should work:
function Teacher(firstName, lastName, roomNumber) { Person.call(this, firstName, lastName); this.room = roomNumber; }