I need a step by step explanation on orderCount


In the below exercise I am trying to wrap my head around about the below:
1. I understand that function takeOrder takes two parameters and it will console log the parameters when passed as arguments.
Problem 1: Why are we using ordercount here? What is the process for it to work? How is order count operating, how can I invoke the function to see what order count does before I pass it as an argument in get subtotal?

var orderCount = 0;
function takeOrder (crustType, topping) {
orderCount = orderCount + 1;
console.log ('Order: ' + crustType + ' pizza topped with ' + topping);

function getSubTotal (itemCount){
return itemCount * 7.5;

function getTax (){
return getSubTotal(orderCount) * 0.06;

function getTotal(){
return getSubTotal(orderCount) + getTax();

takeOrder('thin crust', 'bacon');
takeOrder('thick crust', 'pineapple');
takeOrder('simple crust', 'ham');


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.