30. What are objects for?


#1

Whats going wrong here? I get the error message:
Oops, try again. Make sure to use the Object constructor.

And it gives the ReferenceError: age is not defined

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

// make spencer2 here with constructor notation
var spenser2 = new Object ();
spenser2.age = age;
spenser2.country = country


#2

HI these lines

spenser2.age = age;
spenser2.country = country

where you put age and country .. where you have age put 22 and instead of country put "United States"

#example

var object = new Object();
object.propriety = value;

#3

Hi @wizmarco

Thanks for the feedback but already tried that too:

Now it returns "United States" and gives the error;
Oops, try again. Make sure to use the Object constructor.

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

// make spencer2 here with constructor notation
var spenser2 = new Object ();
spenser2.age = 22;
spenser2.country = "United States";


#4

then here

var spenser2 = new Object ();

remove the space between object and ()


#5

Wooo thanks a million. I felt so stupid having to ask for help at this point since its a real easy exercise!!

But what I still do not understand; why does a space matter? I've been told that all empty spaces between lines of code are neglected?


#6

yes space doesn't matter in Javascript but with the constructor notation the object() doesn't allow space between them. object and ()