Tell us what’s happening:
does anyone know why they’re asking me to define data and friends even though they are object elements? I feel like this one should be easier than it feels like.
Thank you!
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) {
// Only change code below this line
user[data][friends].push(friend)
return user[data][friends]
// Only change code above this line
}
console.log(addFriend(user, 'Pete'));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
.
Challenge: Modify an Array Stored in an Object
Link to the challenge: