user object contains three keys. The data key contains five keys, one of which contains an array of friends. From this, you can see how flexible objects are as data structures. We've started writing a function addFriend. Finish writing it so that it takes a user object and adds the name of the friend argument to the array stored in user.data.friends and returns that array.
user object should have name, age, and data keys.
testString: assert('name' in user && 'age' in user && 'data' in user);
- text: The addFriend function should accept a user object and a friend string as arguments and add the friend to the array of friends in the user object.
testString: assert((function() { let L1 = user.data.friends.length; addFriend(user, 'Sean'); let L2 = user.data.friends.length; return (L2 === L1 + 1); })());
- text: addFriend(user, "Pete") should return ["Sam", "Kira", "Tomo", "Pete"].
testString: assert.deepEqual((function() { delete user.data.friends; user.data.friends = ['Sam', 'Kira', 'Tomo']; return addFriend(user, 'Pete') })(), ['Sam', 'Kira', 'Tomo', 'Pete']);
```