https://www.codecademy.com/courses/learn-intermediate-javascript/projects/build-a-library
In step 5 of this project, we create a setter for the isCheckedOut boolean property of the Media class. In step 6, we then create a method that actually switches the value from false to true or true to false.
set isCheckedOut(newCheckedOut) {
this._isCheckedOut = newCheckedOut
}
toggleCheckOutStatus() {
this._isCheckedOut = !this._isCheckedOut
}
So, my question is, why do we create that setter? The toggle method doesn’t utilize the setter method, and when demonstrating the code later in the exercise, we don’t use the setter either. We just use the method. I’m not even sure how we would use the setter. So what is its purpose? Is it best practice to just have it there even if it’s unused? Is there something that I as a beginner am not seeing?