itemCount's value


#1

Continuing the discussion from Return:

itemCount’s value comes from this line:

let orderCount = 0;

const takeOrder = (crustType, topping) => {
orderCount +=1;

when you declared orderCount as 0 the line:

orderCount +=1; -added 1 to the 0.

At the bottom, takeOrder was called thrice meaning 3 items were ordered.
So itemCount is now 3.

When the line:

console.log(getSubTotal(orderCount));
is applied the
return itemCount * 7.5 -multiplies it with 3.

return itemCount (3) * 7.5

Output is 22.5