Created
July 11, 2020 15:54
-
-
Save pads/99552b1f9290cba068b9516cc5b721f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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