13.introduction t objects. 23 more options


#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 Caulfield";
this.age = 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 );

why it doesn't work? can you help me


#2

Hey @bytemaster58750,

Your coding doubles up. The purpose of creating a custom constructor (your first 4-5 lines), is to save you time and effort.

So for each of your 'people', you only need to write it out once without further iterating on 'this.name', 'this.age' etc as it's already definted in var sally = new Person ("Sally Bowles, 39).

Hope that makes sense?


#3

thank you) @megarockstar25205....i have done it... of course with your help)