From 9e9bc276aa9cd06017f9928bc74ed98ef064ca57 Mon Sep 17 00:00:00 2001 From: CharmedSatyr Date: Sat, 30 Jun 2018 06:58:36 -0500 Subject: [PATCH] fix(challenges): add comments to getter/setter instructions codeblock ISSUES CLOSED: #92 --- .../02-javascript-algorithms-and-data-structures/es6.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenges/02-javascript-algorithms-and-data-structures/es6.json b/challenges/02-javascript-algorithms-and-data-structures/es6.json index 14f1596d4..4be89011b 100644 --- a/challenges/02-javascript-algorithms-and-data-structures/es6.json +++ b/challenges/02-javascript-algorithms-and-data-structures/es6.json @@ -1223,7 +1223,7 @@ "These are classically called getters and setters.", "Getter functions are meant to simply return (get) the value of an object's private variable to the user without the user directly accessing the private variable.", "Setter functions are meant to modify (set) the value of an object's private variable based on the value passed into the setter function. This change could involve calculations, or even overwriting the previous value completely.", - "
class Book {
  constructor(author) {
    this._author = author;
  }
  // getter
  get writer(){
    return this._author;
  }
  // setter
  set writer(updatedAuthor){
    this._author = updatedAuthor;
  }
}
const lol = new Book('anonymous');
console.log(lol.writer);
lol.writer = 'wut';
console.log(lol.writer);
", + "
class Book {
  constructor(author) {
    this._author = author;
  }
  // getter
  get writer(){
    return this._author;
  }
  // setter
  set writer(updatedAuthor){
    this._author = updatedAuthor;
  }
}
const lol = new Book('anonymous');
console.log(lol.writer);  // anonymous
lol.writer = 'wut';
console.log(lol.writer);  // wut
", "Notice the syntax we are using to invoke the getter and setter - as if they are not even functions.", "Getters and setters are important, because they hide internal implementation details.", "
",