Hello, I’m on the Learn Intermediate JavaScript course and trying to solve the Build a Library project of the Classes lesson. (https://www.codecademy.com/courses/learn-intermediate-javascript/projects/build-a-library)
I tried to solve the project without following the steps or watching Matt’s video. I have a few questions:
- Before seeing the solution I used this for the toggleCheckOutStatus() method:
toggleCheckOutStatus() {
this.isCheckedOut ? false : true;
}
I thought that using the ternary operator would work just fine for me, although it doesn’t, the checkout status never changes, any idea why?
- I noticed in Matt’s video that he doesn’t prepend an underscore
_
to the variables of the.getAverageRating()
,.toggleCheckOutStatus()
, and.addRating()
methods . To my understanding, this is because we’ve already declared the necessary setters and getters before. Does this mean that we should use an underscore_
only in the getters and setters declaration and not in the other methods of the class?