23. More Options


#1


https://www.codecademy.com/en/courses/spencer-sandbox/3/4?curriculum_id=506324b3a7dffd00020bf661


Whenever I click submit with my code below, I get the error message: TypeError: undefined is not an object (evaluating 'sally.species').
Not sure where I am going wrong, any help would be greatly appreciated.


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

var sally = Person("Sally Bowles", 39);
var holden = Person("Holden Caufield", 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

While making objects we add the new keyword

Make sure to add new in line 7 and 8 before Person...


#3

Brilliant, thanks, that solved it! I thought since there is a function to create the object, we didn't need to do anything other than call the function. Will remember this for next time.


#4

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

var sally = new Person("Sally Bowles", 39);
var holden = new Person("Holden Caulfield",16);
console.log("a espécie de sally é " + sally.species + " e a idade dela é " + sally.age);
console.log("a espécie de holden é " + holden.species + " e a idade dele é " + holden.age);


#5

No, it's not working for me....Browser maybe? "Maxthon"

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

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

Oh wait, I'm not finished. Yet. Wow I never catch my mistakes until I start complaining. Bad Mister, Bad!!!


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.