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 Object-Oriented JavaScript (2015) Constructor Functions and Prototypes Create a Constructor

Tiffany White
Tiffany White
5,373 Points

I am confused by the instructions here.

Not certain what this is asking: Modify the Monster constructor to take one parameter of name. Inside the constructor function, when it creates a new instance assign the parameter name to the property of name on the new instance.

monster.js
function Monster (name) {

}

2 Answers

Steven Parker
Steven Parker
231,275 Points

Remember that the new instance is referred to as this. So you want something like:

function Monster (name) {
    this.name = name;
}

This is very similar to what was done in the video using Dice and sides.

Tiffany White
Tiffany White
5,373 Points

Yeah I figured it out. Thanks for answering the question though.

Shane Oliver
Shane Oliver
19,977 Points

you need to add a property on the Monster object of name that is equal to the argument of name

this.name = name;