23/33 I'm not sure if this is working correctly


#1

I get an error: TypeError: Cannot read property 'species' of undefined

Whenever I run this code. Problem is, species is already defined in the pre written code, and the hint that comes up when the code is run says that its a problem with the name property. Any pointers?

function Person(name,age) {
this.name = name;
this.age = age;
this.species = "Homo Sapiens";
}

var sally = Person("Sally Bowles", 39);
var holden = Person("Holden Caulfield", 16);
console.log("sally's species is " + sally.species + " and she is " + sally.age );
console.log("holden's species is " + holden.species + " and he is " + holden.age );


#2

On exercise 10 it says..

Another way of creating objects without using the curly brackets { } is to use the keyword new. This is known as creating an object using a constructor.

The new keyword creates an empty object when followed by Object(). The general syntax is:

var objectName = new Object();

In you code it says...

var sally = Person("Sally Bowles", 39);

It should say...

var sally = new Person("Sally Bowles", 39);