Syntax error


#1



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

Oops, try again. Your code threw the following error when sally's name was checked: TypeError: Cannot read property 'name' 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" );


#2

The last two lines are the most revealing. You should be able to see the error.


#3

can u explain it? it's tell me type error


#4

Look for the errors in the last two lines.


#7

i found it not on last two lines. problem on constructor


#9

you have errors on the last two lines. no problem on constructor. look closely at the difference between these:

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


#10

Identifier names are never written in quotes, else they become plain strings.


#11

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