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

JavaScript

am 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

}

Navigate to the Teacher.js and the code below should work:

function Teacher(firstName, lastName, roomNumber) { Person.call(this, firstName, lastName); this.room = roomNumber; }

5 Answers

Teacher 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; 
}

None of these answers are correct. They do not pass

it worked. thanx

teacher.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; };

please, whats the answer? I'm desperate for it. the video is not quit helping.

hey 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; }