Skip to content

Instantly share code, notes, and snippets.

@SebGogo
Created December 11, 2017 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SebGogo/26aa9cae3837fca78c49c8d71f2d2a32 to your computer and use it in GitHub Desktop.
Save SebGogo/26aa9cae3837fca78c49c8d71f2d2a32 to your computer and use it in GitHub Desktop.
Pizza App
// Variable which can change to hold number of pizza orders
let orderCount = 0;
// Function for placing pizza orders including toppings & crust type
const takeOrder = (topping, crustType) => {
// Increment the order numbers by one each time function is called
orderCount++;
// Print the type of pizza ordered after the function is called
console.log(`Orders: ${crustType} pizza topped with ${topping}`);
}
// Function for calculating each orderCount by $7.50
const getSubTotal = () => {
return orderCount * 7.5;
}
// Calling function getSubTotal within function getTax to calculate sales tax of 6% to sub total of pizzas
const getTax = () => {
return getSubTotal() * 0.06;
}
const getTotal = () => {
return getTax() + getSubTotal();
}
// Calling function takeOrder and passing arguments for toppings & crust type
takeOrder('pepperoni', 'thin crust');
takeOrder('pepperoni', 'thin crust');
takeOrder('pepperoni', 'thin crust');
// Calling function getSubTotal with orderCount argument to print sub total of orders
console.log(getSubTotal());
// Calling function getTax to print the sales tax of getSubTotal
console.log(getTax());
// Calling function getTotal to print getSubTotal * getTax for total price
console.log(getTotal());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment