Hey fCC community, I’m having issues with this exercise.
The example given is
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
When I try to do const lotr = new Book(‘Tolkien’);
My result is: ‘Book’ is not defined
Did you write the Book class in the code? You won’t get that error if you did that.
class Book {
constructor(author) {this._author = author; }
get writer(){
return this._author; }
set writer(updatedAuthor){
this._author = updatedAuthor; }}
This is the code, the book class is in there, what am I missing?
If you typed that in the code editor, you should have no problems. I can’t see how else you can get that error.
I’m using https://jsconsole.com/, maybe something is messed up there then
Same thing happened in jsbin.com console
class Book {
constructor(author) {this._author = author; }
// getter
get writer(){
return this._author; }
// setter
set writer(updatedAuthor){
this._author = updatedAuthor; }}
undefined
const lol = new Book('anonymous');
"Book is not defined"
It’s working fine in jsconsole though.

This is a wild guess, but do you literally have the "Book is not defined" string at the end of your code? Maybe that’s what you’re seeing.
No I was just copy pasting the console to show the result here. I’m not sure why the same code for me comes as undefined and works for you.
I’ll figure it out eventually