I dont quite understand the syntax
instructions
Code
In a constructor, we don't have to define all the properties using parameters. Look at our new Person example on line 1, and see how we set the species to be "Homo Sapiens" (line 4). This means that when we create any Person, their species will be "Homo Sapiens". In this way, the values associated with name and age are not yet assigned, but species will always have the same value.
In this case, both sally and holden will have the same species of "Homo Sapiens", which makes sense because that is the same across all people.
Instructions
Create a new object called sally using the Person constructor. Her name is "Sally Bowles" and she is 39. Create another object called holden. His name is "Holden Caulfield" and he is 16.
Edit the sentence printed out such that it includes the age of sally and holden respectively.
my code
Code
function Person(name,age) {
this.name = name;
this.age = age;
this.species = "Homo Sapiens";
}
var sally = new Object(Person){
sally.name = "Sally Bowles";
sally.age = 39;
sally.species = "";
}
var holden = new Object(Person){
holden.name = "Holden Caulfield";
holden.age = 16;
holden.species="";
}
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);