Created
July 11, 2020 15:51
-
-
Save pads/96fa1500f97303fc0b7924d739cec2ab to your computer and use it in GitHub Desktop.
This file contains 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-2.js | |
/* | |
A person named Alice is defined below. | |
Add a method "sayName" so this person can say their own name. | |
Hint: use 'this' keyword to access the name property. | |
*/ | |
let person = { | |
name: "Alice", | |
age: 25, | |
sayName: function () { | |
return "My name is " + this.name | |
} | |
}; | |
/* | |
DO NOT EDIT ANYTHING BELOW THIS LINE | |
*/ | |
console.log(`Expected result: 'My name is Alice'. Actual result: ${person.sayName()}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment