Hi everyone,
Here is the link to this project
https://www.codecademy.com/courses/introduction-to-javascript/projects/meal-maker
Also here is the link for something I previously posted about this project
I’ve been reviewing the exercises to Intro JS, and I’ve stumbled again with some doubts I hope this community can help clarify. Thank you all in advance! Let’s do this!
Doubts:
Like I had mentioned in my previous post about this project (link above) the getters and setters are not having an impact in generating a random meal… but I also now realize they don’t do much for the purpose of “setting” a new dish (?)
- Shouldn’t we add data (dishes) via the setters? It feels to me there is something confusing my brain
that I cannot really put my finger on, an incongruence of sorts. Let me see if I can put some of this to words: it looks like we always want to couple a specific price to a specific dish when adding data. Because of that, we are leaving the setters out to dry, and they are not doing anything in terms of adding data:
- a) shouldn’t we add data via our setter method, which should incorporate a price parameter?
- b) or is my sense of confusion coming maybe from misunderstanding the role of a setter versus that of a method that pushes data? (and when would we use one or the other, for the purpose of adding data?)
- A final question: we decided to wrap the appetizers, mains, desserts, into a _courses object.
- When do I know if I want to use curly braces or square brackets? I mean
, it seems to me objects and arrays are almost interchangeable – couldn’t we have also defined _courses as an array (of appetizers, mains, desserts), and couldn’t we have set appetizers, mains, desserts as objects (namely with a name and price) instead of arrays?
- And if there is this interchangeability between arrays and objects, when do we decide to use one or the other?
Thanks for any ideas on this!
Pedro