From Javascript, Basic Data Structures: Modify an Array Stored in an Object
My first solution to the problem was
function addFriend(userObj, friend) {
// Only change code below this line
return userObj.data.friends.push(friend);
// Only change code above this line
}
but it return 4, which isn’t right. then I got confused and look at the solution which is:
userObj.data.friends.push(friend);
return userObj.data.friends;
the solution 's method return [ ‘Sam’, ‘Kira’, ‘Tomo’, ‘Pete’ ]
why does my code return 4 and not [ 'Sam', 'Kira', 'Tomo', 'Pete' ]
Learn Basic Data Structures: Modify an Array Stored in an Object | freeCodeCamp.org