Skip to content

Instantly share code, notes, and snippets.

@pads
Created July 11, 2020 15:51
Show Gist options
  • Save pads/96fa1500f97303fc0b7924d739cec2ab to your computer and use it in GitHub Desktop.
Save pads/96fa1500f97303fc0b7924d739cec2ab 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-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