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

Create 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.

monster.js
function object() {}
var monster = new monster();
Jacob Bender
Jacob Bender
15,300 Points

Try

function monster() {};
var myMonster = new monster();

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

3 Answers

Thanks 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.

The function is case sensitive so you must ensure your Monster is with a Capital M ;)

function monster() {};
var myMonster = new monster(); 

Doesn't see to work.

Below worked for me..

function Monster() {
}