Editing an object:Please help


#1

var myObject = {
name: 'Eduardo',
type: 'Most excellent',
interests:'cricket',

};

what is wrong with this code?Please help


#2

Hi, What error are you getting?


#3

I have same problem. Can someone help me please?

var myObject ={
name: 'Eduardo',
type: 'Most excellent',
interests:'Reading books',

};


#4

I even tried this.......
var interests = ["me", "you", "Reading books"]
var myObject ={
name: 'Eduardo',
type: 'Most excellent',
interests:'cricket',

};


#5

Instructions for this exercise, tell us to:

Add a key called interests to myObject. Give this key an array value (the array can contain whatever you like).

So, adding interests as a variable is wrong. You have to assign a "key" to myObject. Remember that objects are key-value pairs like this:

var object = {
    key1: value1,
    key2: value2,
    key3: value3
    [and so on...]
}

#6

var myObject = {
name: 'Eduardo',
type: 'Most excellent',
interests: 'Boxing',

};

can anyone help?
error message - Oops, try again. Did you give your interests key an array value?

thanks


#7

See the value you gave to interests key:

interests: 'Boxing',

and then read the error message:

Oops, try again. Did you give your interests key an array value?


#8

maybe you can try this:

var myObject = {
name: 'Eduardo',
type: 'Most excellent',
interests: ["Boxing"]
};


#9

What you posted=
"I even tried this.......
var interests = ["me", "you", "Reading books"]
var myObject ={
name: 'Eduardo',
type: 'Most excellent',
interests:'cricket',

};"

All you need to change is the value for the interest key. instead of 'cricket' put the name of the array you created.


#12