Create a working function that would be a helpful tool for waiters that logs what a customer wants to order?
function takeOrder(topping, crustType) {
console.log('Order type: ' + crustType + 'pizza topped with ' + topping);
}
takeOrder(pineapple and ham, thick crust);When functions return their value, we can use them together and inside one another. How can you expand onto a function that takes the orders for customers and gets the subtotal, the tax, and the grand total?
Var orderCount = 0;
Function takeOrder(topping, crustType) {
console.log(‘Order: ’ + crustType + ‘ pizza topped with’ + topping);
orderCount = orderCount + 1;
}
function getSubTotal (itemCount) {
return orderCount * 7.50;
}
Function getTax () {
return getSubTotal(orderCount) * 0.06;
}
Function getTotal () {
return getSubTotal(orderCount + getTax());
}
takeOrder(‘pineapple and ham’, ’thick crust’);
console.log(‘Your subtotal is:’, getSubTotal(orderCount))
console.log(‘Your total is:’ getTotal)
Whats the difference between where a global variable can be accessed and where a functional variable can be accessed?
A global variable can be accessed anywhere and a function variable can only be accessed within it’s function