Hello
My question is - why do I need itemCount? I understand it’s a local variable, while orderCount is a global one. Why can’t I use only the orderCount like below? It seems to be working and there’s less code to write.
MY SOLUTION:
let orderCount = 0;
const takeOrder = (topping, crustType) => {
console.log('Order: ’ + crustType + ’ pizza topped with ’ + topping);
orderCount++;
};
const getSubTotal = () => {
return orderCount * 7.5;
}
takeOrder(‘mushroom’, ‘thin crust’);
takeOrder(‘spinach’, ‘whole wheat’);
takeOrder(‘pepperoni’, ‘brooklyn style’);
console.log(getSubTotal());
ORIGINAL SOLUTION:
let orderCount = 0;
const takeOrder = (topping, crustType) => {
console.log('Order: ’ + crustType + ’ pizza topped with ’ + topping);
orderCount++;
};
const getSubTotal = (itemCount) => {
return itemCount * 7.5;
}
takeOrder(‘mushroom’, ‘thin crust’);
takeOrder(‘spinach’, ‘whole wheat’);
takeOrder(‘pepperoni’, ‘brooklyn style’);
console.log(getSubTotal(orderCount));