29. Is it my code?


#1


https://www.codecademy.com/courses/spencer-sandbox/4/4?curriculum_id=506324b3a7dffd00020bf661#


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));


#2

@gigglee,

Have a close look at

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


#3

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


#4

@gigglee,

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

and

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

Addendum
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


#5

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


#6

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