Build a Library - Task 6 (Unstuck Video - Need more detail on not changing raw values)

Link to course lesson/project - Build a Library

In the video solution the developer says something about raw values not needing to be updated, and I would like to further my knowledge of what exactly he means by this. Timestamp: 5 minutes 25 seconds

Issue: I do not understand how the running of the Media.toggleCheckoutStatus() has an impact on the getter and setters within the same class.

Please do let me know if I need to offer more information, but I want to get this logic down 100%.

Currently all I believe I know is this:

  1. Method is called using the Class Name + the Method name ( ‘Media.toggleCheckoutStatus()’ )
  2. ???
  3. The status of ‘isCheckedOut’ is changed due to that toggle method being called - True/False


  • What happens between steps 1 and 3?
  • How does the Setter get contacted and passed its value?
  • What value is passed into this setter method to update the isCheckedOut property?

I was unable to find any thread directly addressing these questions with relation to this project.

Happy to review another thread if one exists.

In truth, we call the method on the instance not the class.

myLibrary = new Media('Catch-22')

console.log(myLibrary.isCheckedOut())    //  false

The setter is activated by assigning a new value to the property.

this.isCheckedOut = ! this.isCheckedOut

much the same as we would in a normal object with no setter. and we poll the variable with the getter much the same way we would poll a property of a normal object.

Notice above we engage the getter to poll the property rather than use the underscore property directly. That code, btw will be in the toggleCheckoutStatus() method.

Also note that the value we pass in is nothing. It polls the property to get the current value then sets it to the opposite.