More Options/ 23/33/ Please help!


#1

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

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


#2

Hi
you should not add the
{
this.name = "Sally Bowles";
this.age = 39;
};

and
{
this.name = "Holden Caufield";
this.age = 16;
};

after the two
var sally = new Person("Sally Bowles", 39);
var holden = new Person("Holden Caulfield", 16);

These lines are valid for functions only. The data is transferred to the function through the parameters given in parentheses.


#3

Still gives me the Syntax error Unexpected tokken )


#4

in the two console.log, you have forgotten the sally.age and holden.age after the last + sign, as asked in the instructions


#5

George2395,
You want to make sure that when you are using the constructor to create a new person that you use the "new" keyword in when you define the variable that creates the new person.

// 23. More Options
//------------------------------------------------------------------------------------
function Person(name,age) {
this.name = name;
this.age = age;
this.species = "Homo Sapiens";
};

var sally = new Person("Sally Bowles", 39); // Note the new Person() when using the Person constructor.
var holden = new Person("Holden Caulfield", 16);

//log the results...
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);

//------------------------------------------------------------------------------------

This should return the correct information as it creates the new person using the Person constructor. You can see it first used in lesson 21. Custom Constructors.

Cheers,
- Jorge!