29. Is it my code?



Uhhh?? Who's timmy? Where is this coming from? I'm 90% sure my code is correct.

TypeError: timmy is not a function (evaluating 'console.log("The older person is " + olderAge(alice, billy))')

// Our person constructor
function Person (name, age) {
    this.name = name;
    this.age = age;

// We can make a function which takes persons as arguments
// This one computes the difference in ages between two people
var ageDifference = function(person1, person2) {
    return person1.age - person2.age;

// Make a new function, olderAge, to return the age of
// the older of two people
var olderAge =  function(person1, person2) {
    if(person1.age a > person2.age) {
    return person1.age;
    } else {
        return person2.age;

// Let's bring back alice and billy to test our new function
var alice = new Person("Alice", 30);
var billy = new Person("Billy", 25);

console.log("The older person is " + olderAge(alice, billy));



Have a close look at

if(person1.age a > person2.age) {


oh heh... well aside from that, still same error



You will have to do a refresh Browser.....

++++ reset of session *****************
As you are manipulating with objects
under certain circumstances you can shoot your Browser in an
inconsistent state.

Therefor it is of an advantage to know that you have 2 reset facilities:

One is the use of the F5-key which does a refresh Browser


Two, select&copy your code
Then use the Reset Code button of the course-window,
then paste your code back in.

General Notes:
Always refresh the browser after making corrections:
CTRL f5 ( if on Windows or Linux)
CMD r ( if on a MAC).
CTRL 0 to reset browser zoom


I feel so dumb for not thinking of that, thanks a lot


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.