Wheres my code wrong? lesson 16


#1



Replace this line with your code. 

var myArray=["jogg","sing"];
var myObject = {
  name: 'Eduardo',
  type: 'Most excellent',
  // Add your code here!
  interests: myArray;
  
};


#2

Literal syntax:

var myObj = {
key1: value, // note ,
key2: value
};

interests: myArray; //wrong
@jay8978


#3

Not wrong, just risky.

console.log(myObject.interests)    // [ 'jogg', 'sing' ]

It's risky in that the data is outside of the object, proper, and vulnerable since it could easily be overwritten by a mis-declared variable in a function:

function foo() {
    myArray = ['cat', 'dog', 'canary', 'hamster', 'ant farm']
    for (var pet = 0; pet < myArray.length; pet++) {
        console.log(myArray[pet]);
    }
:}
foo()

console.log(myObject.interests);    
//  [ 'cat', 'dog', 'canary', 'hamster', 'ant farm' ]

Just like that myObject's interests became someone's pet list.