Construction junction(more options)


#1

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

ERROR : Your code threw the following error when sally's name was checked: TypeError: sally is undefined

Where is the he Error ? help


#2

if you want to create a new object, you need the new keyword. So: var sally = new Person("Sally Bowles",39)