Modify an Array Stored in an Object

Modify an Array Stored in an Object


Tell us what’s happening:
Hello, i’m stuck… i cant seem to pass this, don’t know what i’m getting wrong

Your code so far

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

function addFriend(userObj, friend) {
  // change code below this line;
	return user;
  // 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/67.0.3396.87 Safari/537.36.

Link to the challenge:


I think in the addFriend function, change user to userObj.


Tip: you have to return the “friends” array.



Actually, when reading the exercise description, the list of friends should be returned, not the whole user object.


Finish writing it so that it takes a user object and adds the name of the friend argument to the array stored in and returns that array


Thanks guys, my code worked after i returned the . i was getting the instruction a bit confusing. Happy coding!