What objects are for?


#1


What's wrong with this TT


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

// make spencer2 here with constructor notation
var spencer2 = {};
    spencer.age: 22;
    spencer.country: "United States";


#2

Hi @christinecillo,

spencer.age: 22;
spencer.country: "United States";

When we want to assign a value to a variable ,we use assignment operator ( =)
here you are adding key:value pairs to object using the keys,We need to use = operator.

(one more thing to note that your second object is spencer2 not spencer)

Read instruction again , there should be some changes in value of second object too.


#3

oh I see. Thanks so much


#4

but I already changed the values. the syntax said that I must use object contructor


#5

We will create object using Constructor Notation like this..

suppose my object is x

then I will create object like this..

var x = new Object();
We define the variable and then use keyword new before Object() .

Note: Your object is spencer2.

I highly suggest to read the theory once more.


#6

Does not work for me still says it needs to be a Object constructor! Please help! Here is my code if you want to take a look
var spencer = {
age: 22,
country: "United States"
};

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


#7

Take a look at this ,line, Its buggy.
Check syntax.


#8

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