I have been sitting on this problem for 2 days now and I haven’t been able to come up with an applicable solution to it.
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-data-structures/modify-an-array-stored-in-an-object
I somehow managed to get this far.
function addFriend(userObj, friend) {
// Only change code below this line
user.data.friends.push(friend)
return user.data.friends.splice(friend);
// Only change code above this line
}
console.log(addFriend(user, 'Pete'));
I feel abit lost there and I am trying to figure out how to do it…