Skip to content

Conversation

@debasrid
Copy link

No description provided.

Copy link

@lienekechee lienekechee left a 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

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
});

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:

  1. 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?
  2. 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 }];

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants