Skip to content

Instantly share code, notes, and snippets.

@pads
Created July 11, 2020 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pads/99552b1f9290cba068b9516cc5b721f0 to your computer and use it in GitHub Desktop.
Save pads/99552b1f9290cba068b9516cc5b721f0 to your computer and use it in GitHub Desktop.
// https://github.com/CodeYourFuture/JavaScript-Core-2-Homework/blob/master/Week-1/InClass/D-methods/exercise-4.js
/*
Alice has a list of good friends.
Define a method "makeFriend" to add a new friend to her list.
*/
let person = {
name: "Alice",
friends: ["John", "Nina"],
makeFriend(newFriend) {
this.friends.push(newFriend);
}
};
/*
DO NOT EDIT ANYTHING BELOW THIS LINE
*/
person.makeFriend("Bob");
console.log(`Expected result: 'John,Nina,Bob'. Actual result: ${person.friends}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment