Editing an existing object..help needed


#1


https://www.codecademy.com/courses/javascript-beginner-en-9Sgpi/3/3?curriculum_id=506324b3a7dffd00020bf661#


I'm not sure why this appears: "Did you give your interests key an array value?"


var myObject = {
  name: 'Eduardo',
  type: 'Most excellent',
  interests: 'Something'
};
var myArray= [4, 3, true, myObject];
console.log(myArray[3].interests);


#2
> "Did you give your interests key an array value?"

myArray[3].interests

myArray[3] represents 3rd item which is myObject (which is an object).
to access interests (it is object's key) value from myObject we write something like this...
myObject["interests"]

Do you get the hint?
I hope it helps! :slight_smile:
do reply if it solved your problem or not!


The above thing is not relevant !

Update !! I just read the problem which says...

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

myObject should have a key named interests and corresponding to this key ,we have to put an array as value!

suppose I want to add an array to an Object in this example...

x = {}
x.hobbies = ["coding" ,"food" , "music"]

then the final object will look like this..

x = {hobbies: ["coding" ,"food" , "music"]}

I hope it helps!!


#3

Thanks!! Im a bit confused...."interests" is a key to myObject and 'Something' is its value. Im not sure what I'm doing wrong :confused:


#4

ok this seem clear, I will try this....will let you know my results. thanks!


#5

Sure!! :slight_smile:


#6

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