Hi,
I would like to correctly understand what is it explain in this course.
Are my comments rights ?
class Book {
constructor(author) { /* is used by const lol = new Book('anonymous'); */
this._author = author;
}
// getter
get writer(){ /* is used by console.log(lol.writer); */
return this._author;
}
// setter
set writer(updatedAuthor){ /* is used by lol.writer = 'wut'; */
this._author = updatedAuthor;
}
}
const lol = new Book('anonymous');
console.log(lol.writer);
lol.writer = 'wut';
console.log(lol.writer);
For example, if I use const lol = new Book('anonymous');
only, we’ll only use the constructor part, is that right ?
Maybe I’m completly wrong haha
Thanks in advance,
Quentin
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-getters-and-setters-to-control-access-to-an-object