29 Try It Out Why Doesn't this Code Work?


Hey, I eventually got the right answer but initially I tried using this in my if statement:
var olderAge = function(person1, person2){
if(ageDifference > 0){
return person1.age;
return person2.age;

It seems like this should work but it didn't. Is there a reason I can't use the ageDiffence function inside the if statement of the olderAge function?



Hi you declare a function olderAge with two argument person1, person2 so you should use Them inside your if condition.. if person1 great than person2 return person1 age otherwise return person2 age


Got that. Just wonder why the other solution doesn't work as well.


Wondering the same thing: why does

console.log(person1) fail, while

return person1 works just fine.