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 trialBozin Madenski
Full Stack JavaScript Techdegree Student 773 PointsCan't figure it out
help
function Monster (name) {
};
var newMonster = Monster.name("Name");
3 Answers
Adam N
70,280 Pointsfunction Person(first, last, age, eye) {
this.firstName = first;
this.lastName = last;
this.age = age;
this.eyeColor = eye;
}
^ example of a good constructor
function Monster (name) {
};
^ start your attempt from that point.
Steven Parker
231,269 PointsHere's a few hints:
- the instruction say to assign the property "Inside the constructor function"
- the name of the property should be "name" (not "newMonster")
- property names should be preceded by "this."
- don't put quotes around the parameter name
Jonathan Grieve
Treehouse Moderator 91,253 PointsHi Bozin,
You want to use the .this
syntax inside your constructor function.
You don't need to create a new instance of the constructor in the code challenge, all you do is set the properties of the constructor.
So...
this.name = name