Concept explainers
(a)
To add the calcPizzaPrice() method to the pizza object prototype with the size property, setting the value of the pizza’s price property to either the value of the size12, size14, or size16 property of the pizzaPrice object in file rb_build.js.
(b)
To add the pizza crust equals “stuffed” or “pan”, by increasing the value of the price property by the corresponding values of the stuffed or pan properties of the pizzaPrice object in the calcPizzaPrice() method to the pizza object prototype in file rb_build.js.
(c)
To check if the doubleSauce or doubleCheese values are true, then increasing the price by the corresponding value of the doubleSauce or doubleCheese properties of the pizzaPrice object in the calcPizzaPrice() method to the pizza object prototype in file rb_build.js.
(d)
To create a for loop through the contents of the toppings array and for each topping, for calculating the qty property of the topping multiplied by the value of the topping property of pizzaPrice and adding the value to the pizzaPrice object in the calcPizzaPrice() method to the pizza object prototype in file rb_build.js.
(e)
To return the final calculated value of the price property to the pizzaPrice object in the calcPizzaPrice() method to the pizza object prototype in file rb_build.js.
Want to see the full answer?
Check out a sample textbook solutionChapter 14 Solutions
New Perspectives on HTML5, CSS3, and JavaScript
- New Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage Learning