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 trialVeronica Rivera
32,599 PointsCreate a Constructor Task 1. I do not understand what it is asking me to do.
I do not understand what it is asking me to do. It says to create a constructor called monster and don't put in any parameters or properties. Yet it says "monster is not a function." This is what I think it means but I am stuck. Please help.
function object() {}
var monster = new monster();
3 Answers
Veronica Rivera
32,599 PointsThanks Jacob for your answer. I got the correct answer so I will share this with you all.
function Monster() {
}
I had this answer at first but I had "monster" and I thought it meant it didn't want monster to be the function which didn't make sense. Turns out it wanted me to put "Monster" capitalizing the first letter. Lol.
Tara Schott
7,665 PointsThe function is case sensitive so you must ensure your Monster is with a Capital M ;)
Mike Siwik
Front End Web Development Techdegree Student 14,814 Pointsfunction monster() {};
var myMonster = new monster();
Doesn't see to work.
Below worked for me..
function Monster() {
}
Jacob Bender
15,300 PointsJacob Bender
15,300 PointsTry
Your class is monster, and you are making a new instance of that monster class. Your code right now is trying to make an instance of an object that does not exists. Also, it is a good idea to name your instance something varied from the class (if you had a student class, saying var student = new Student(); is not as good for readability as var John = new Student();
Also note that in the first part of this, function Monster() {}; is enough, you don't even need the var monster = new Monster(); bit