fix(challenges): add comments to getter/setter instructions codeblock
ISSUES CLOSED: #92
This commit is contained in:
committed by
Kristofer Koishigawa
parent
1b8eb67726
commit
9e9bc276aa
@ -1223,7 +1223,7 @@
|
||||
"These are classically called <dfn>getters</dfn> and <dfn>setters</dfn>.",
|
||||
"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.",
|
||||
"<blockquote>class Book {<br> constructor(author) {<br> this._author = author;<br> }<br> // getter<br> get writer(){<br> return this._author;<br> }<br> // setter<br> set writer(updatedAuthor){<br> this._author = updatedAuthor;<br> }<br>}<br>const lol = new Book('anonymous');<br>console.log(lol.writer);<br>lol.writer = 'wut';<br>console.log(lol.writer);</blockquote>",
|
||||
"<blockquote>class Book {<br> constructor(author) {<br> this._author = author;<br> }<br> // getter<br> get writer(){<br> return this._author;<br> }<br> // setter<br> set writer(updatedAuthor){<br> this._author = updatedAuthor;<br> }<br>}<br>const lol = new Book('anonymous');<br>console.log(lol.writer); // anonymous<br>lol.writer = 'wut';<br>console.log(lol.writer); // wut</blockquote>",
|
||||
"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.",
|
||||
"<hr>",
|
||||
|
Reference in New Issue
Block a user