Modify an Array Stored in an Object question

Modify an Array Stored in an Object question
0

#1

Tell us what’s happening:
For some reason this doesn’t validate the last rule. Is there a notable difference between the dot and bracket notation?

Your code so far


let user = {
  name: 'Kenneth',
  age: 28,
  data: {
    username: 'kennethCodesAllDay',
    joinDate: 'March 26, 2016',
    organization: 'freeCodeCamp',
    friends: [
      'Sam',
      'Kira',
      'Tomo'
    ],
    location: {
      city: 'San Francisco',
      state: 'CA',
      country: 'USA'
    }
  }
};

function addFriend(userObj, friend) {
  // change code below this line  
userObj["data"]["friends"].push(friend);
  // change code above this line
}

console.log(addFriend(user, 'Pete'));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-data-structures/modify-an-array-stored-in-an-object


#2

According to the instructions, your function is supposed to return an array. Your function does not explicitly return a value, so it returns undefined by default.Make sure to follow all the instructions in the challenge to successfully complete this challenge.