function people (name, age) {
this.name = name;
this.age = age;
}
var rob = new people("robert jr", 41);
var sam = new people("sam davies", 25);
function isOlderThan(age) {
if(rob.age > sam.age)
return true;
else return false;
}
I tried running it with this sam.isOlderThan(rob);
But it's not working. I'm kinda new to this, any help?
ageargument anywhere. Your function simply checks ifrobis older thansam, every single time. Nor isisOlderThana method ofsam.peoplehas no.isOlderThan()method. Why do you thinksam.isOlderThan(rob)should work? (and constructor functions, functions that will be used with thenewkeyword, should start with a capital letter)isOlderThan(), i get back 'true', since rob is older than sam.