Functions 5 RETURN


#1

I don't understand why the parameter 'itemCount' is introduced in the getSubTotal function. Shouldn't it be 'orderCount'?

i.e. getSubTotal(orderCount){
return orderCount * 7.5


#2

Hi @badger64

Yes and no... Yes, the value IS itemCount when you CALL the function getSubTotal(orderCount), however, when you're DEFINING the function, you need to use a different variable, in case you ever need to call getSubTotal(orderCount) on a value other than that of itemCount.

So, long story short; when defining a function, you need to use a different variable parameter than when you're calling it.


#3

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