Function return ||


I think I'm starting to get over the barriers of this excercise but am having a hard time trying to understand one thing.
Can someone explain to me itemCount vs. orderCount? Took me forever to get over because I don't get why itemCount is even used.
The only place it is inserted is in the getSubTotal function. I don't understand why it wouldn't be orderCount considering that's the varibale used to count how many pizzas are ordered.

Any explanation of how this works would be fantastic. I;ve looked through all the forums on this and people just explain how to get over the humps in the code, but not really how it all works together.


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', 'sausage' );
takeOrder('deep dish crust', 'pineapple');
takeOrder('hand tossed crust', 'pepperoni');



You need itemCount to know the price of one pizza.

There's no point knowing how many pizzas to sell if you don't have the unit price in the first place :wink:

Don't forget that itemCount is a parameter of your getSubTotal function, which is called in the console.log.


Hey There All Blacks Fan :slight_smile:
You missed only one part at the end

P.S.From Maori All Blacks Supporter :slight_smile: ..


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