Skip to content

Instantly share code, notes, and snippets.

@pads
Created July 11, 2020 15:53
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/84105c1083d64edf41a46525665a8f5f to your computer and use it in GitHub Desktop.
Save pads/84105c1083d64edf41a46525665a8f5f 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-3.js
/*
The following code contains syntax errors - try and fix them!
Once you fix them, run this file, it should output the correct values!
*/
let person = {
name: "Alice",
age: 25,
currentAddress: "Glasgow",
changeAddress: function(newAddress) {
this.currentAddress = newAddress;
},
celebrateBirthday: function() {
this.age = this.age + 1;
}
};
/*
DO NOT EDIT ANYTHING BELOW THIS LINE
*/
person.changeAddress("Edinburgh");
console.log(`Expected result: Edinburgh. Actual result: ${person.currentAddress}`);
person.celebrateBirthday();
console.log(`Expected result: 26. Actual result: ${person.age}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment