Use getters and setters to Control Access to an Object : Underline with/without author

Hello!

I have a question about the example.

  1. Why are there “author” and “_author”?
    What is underline for?
  2. I am using CodePen to check the code.
    But it doesn’t overwrite the properties of lol.writer with this code -> lol.writer = ‘wut’;
    Is it because I am using CodePen or wrong code?

Thank you your help in advance!!

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**

about the underscore…

It is just a way to clarify the difference between the local variable author and the property referencing the local variable value of author. The underscore character is just another valid character which can be used in variable names and/or property names.

Then is it mandatory to use underscore? I think i don’t fully understand this, and is a pitty that this is not covered in the lesson