I am glad this was asked. itemCount completely threw me off this whole lesson, made the whole thing very confusing. I am more confused about how this even works with itemCount since we never assigned it a value?
Regarding that questions, I would like to share a few previous topics that have been asking about similar issue and have been answered several times. Hope you guys can refer some of them:
The post above explains @doraemonpumpkin’s question about why there is no need to define itemCount, because when orderCount (the argument) get called in the function, in this code:
the value of orderCount is then passed as replacement of itemCount (which is the parameter) and the code inside the function will be interacting with that particular value pass to it.
And yes, @gigawhiz32951, you also can have orderCount as parameter (but it is not the best way to do it when you have thousand lines of code mixing parameter and argument with global variable)
In the end parameter (itemCount) serves as a placeholder only to be passed in a real value when the function is called. In this case, orderCount holds the value. If anyone is curious about other variation of questions and explanations, I have cataloged a few of the similar topics under my post here:
About why itemCount needs to be the parameter? That’s just the author’s choice I think. When you learn further, global variable is not always a good thing to have. Maybe the lesson just intended for the learners to learn about the variation of coding parameter, passing argument with function calling, as itemCount the parameter is passed with orderCount a variable which hold numerical value, while topping and crustType parameters to be passed with string values as arguments during function calling.