Function return ||


#1

https://www.codecademy.com/courses/learn-javascript/lessons/functions/exercises/return-ii?action=lesson_resume

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.

Thanks.

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');

console.log(getSubTotal(orderCount));


#2

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.


#3

Hey There All Blacks Fan :slight_smile:
You missed only one part at the end
console.log(getTotal());

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


#4

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