What is the userObj bit in this answer? I’ve never written an object that way where I put the name of the key followed by ‘Obj’. I had to look up the answer for this one because there was no way I could have known to type it as ‘userObj’. This isn’t defined anywhere and nowhere else was I told to write it this way. I was told in previous lessons to type it as key.subthing.subthing2 or key[subthing][subthing2].
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);
return userObj.data.friends;
// 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/69.0.3497.100 Safari/537.36.
Link to the challenge: