Functions, Part 5


i'm very confused here, could someone explain the difference between itemCount and orderCount, replacing either with each other doesn't make any difference to the output, and since itemCount isn't mentioned in the first function,it seems like its plucked from thin air, it seems like itemCount should be replaced with orderCount
Any explanations would be greatly appreciated.


What information are you trying to get from itemCount/orderCount? Where was that information defined? Use that


thanks for the reply,
just not sure why they used itemCountinstead of the established variable orderCount :slight_smile:


itemCount is only a parameter for getSubTotal. orderCount is already defined and so is passed in as the value for itemCount. You could rewrite the function as

function getSubTotal(){
    return orderCount * 7.5

and then just return getSubTotal() in each case in the getTax() and getTotal() functions, and I don't really understand why it isn't done like this, but oh well :confused: