-
Notifications
You must be signed in to change notification settings - Fork 1.2k
completed #728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
completed #728
Conversation
lienekechee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice Debby!
| var pizzaTotalPrice = [{ type: '', price: 0 }]; | ||
|
|
||
| // create object containing base pizza price | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be super nice to use a constructor function here!
function Topping(type, price) {
}
| type: "greenPepperTopping", | ||
| price: 1 | ||
| }); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try our best to avoid duplicate code; normally if you have to repeat the same kind of thing over and over again, its more appropriate to write a function, this is what they are for. Some things to think about when setting up your program:
- What are the collections of data that I need to store? Since your toppings and your prices don't change, we can declare them immediately in an array, and have a separate array for prices. Maybe even the type strings can correspond to the class name of the button. Do you see how that might be helpful?
- There are default settings for this pizza page. Perhaps setting up all your variables in one place then writing a
setupDefaultView()function that sets up initial toppings and prices, or something similar, could be a little clearer.
|
|
||
| // array to calc final pizza price | ||
| var pizzaTotalPrice = [{ type: '', price: 0 }]; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this variable is better named something like pizzaPrices, since you still have to calculate the total prices later.
No description provided.