30. What are Objects for?


#1

I have the following code for implementing the constructor notation:

var spencer = {
age: 22,
country: "United States"
};

// make spencer2 here with constructor notation

var spencer2 = new Object(); {
this.age = 22;
this.country = "United States";
};

It hasn't given any syntax errors, so I assume I've got the notation right, but says:
"Oops, try again. Make sure that spencer and spencer2 have the same value for age"

but in my code both are 22!

Please help


#2

FYI if I put

"console.log (spencer2.age);" or "console.log (spencer2.country);" at the end of my code the console shows "undefined"! :-s


#3

Sorry just realised the curly brackets weren't required.


#6