Javascript Lesson 23. More Options: Sally and Holden


#1



https://www.codecademy.com/en/courses/serpencer-sandbox/2/6?curriculum_id=506324b3a7dffd00020bf661


With this exercise, no matter what I do, I keep getting syntax errors that the species variable is undefined, that the age variable is undefined, etc. even after initializing the variables using the provided function.

"TypeError: Cannot read property 'species' of undefined"


Once setting the variable "sally" and setting the name and age, I would expect that these variables would then be defined. For some reason, there doesn't seem to be persistence with any of the variables defined using the Person() function, and so nothing done with that function makes a difference outside the scope of said function. I have been stumped on this step for over a week now.


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

the exercise url leads to a 404 page, can you please post an updated url?


#3

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