What is the reason why this is returning me 4 instead of returning the array [“Sam”, “Kira”, “Tomo”, “Pete”]
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
for(let a in userObj){
let array= user.data.friends;
let newFriend=array.push(friend);
return newFriend;
}
// Only change code above this line
}
console.log(addFriend(user, 'Pete'));