More Options - creating Sally and Holden objects


#1


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


Hi! I created the Sally and Holden objects, then added their age properties to the console log. What am I missing or what did I do incorrectly?

The error message says: "TypeError: Cannot read property 'species' of undefined"


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);

Thank you for your help!


#2

When invoking a constructor, be sure to use the new operator.


#3

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