Meal Maker, why getters and setters?


#1

Why do we need to add setters and getters in the Meal Maker exercise? My impression is that they are not necessary to make the code work.
Hope you can clarify.
Many thanks
Link to the project https://www.codecademy.com/courses/introduction-to-javascript/projects/meal-maker


#2

At the moment, getters and setters do not add much value (in my opinion)

however, using getters and setters are very useful if you would like to expand the project, functionality you could add for which getters and setters are very useful:

  • You can check if new data is valid before setting a property.
  • You can perform an action on the data while you are getting or setting a property.
  • You can control which properties can be set and retrieved.