I don’t understand why using getters is necessary. I tested the code, and it works exactly the same if you declare energyLevel() as a regular function, and then when you log it, you just have to call it with parenthesis, like a standard function.
Codecademy provided a few reasons for using getters:
- Getters can perform an action on the data when getting a property.
- Getters can return different values using conditionals.
- In a getter, we can access the properties of the calling object using
- The functionality of our code is easier for other developers to understand.
The only one that seems legitimate to me is the last reason, simply that using the get keyword can help make your code aka your intention, more readable to others. But can’t you achieve the first three things on that list with a standard function?