23/33: Cannot read property 'name' of undefined


#1

Here's my code:

function Person(name,age) {

this.name = name;
this.age = age;
this.species = "Homo Sapiens";
}

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

When I run the code, I get an error: TypeError: Cannot read property 'species' of undefined

Can someone please help?


#2

add a paretheses after Bowles and remove the one from , 35 on line 5 and 6


#4

You need to add new before Person.

change that to

 var sally = new Person("Sally Bowles", 35);
 var holden = new Person("Holden Caufield", 16);

Another thing is you forgot the semi colons after the variables. And you might get an error if you try to submit that code in for lesson 23 because Holden's last name is not spelled correctly, and Sally's age isn't correct either.
:smile: