Problem with incrementing


Hi. I am learning Javascript currently, and I input this code:


function takeOrder(ordercount){

function getSubTotal(itemCount){
return itemCount*7.5;


I set the takeOrder function to increment its parameter by 1 (as seen in the function definition). However, when I run the code, the parameter does not increment. The console.log for orderCount stays put at zero (the value i assigned at the beginning), and I do not know why.

Please could you help with this?

Thanks very much,



function parameters have a local scope (they only exist inside the function), so the global variable doesn’t change


Thanks so much for the reply.

So how do I modify the program to increment the variable orderCount?

I tried putting the console log statement inside the function, but even with that, the ordercount does not show an increment. Shouldn’t it print the incremented version, since


If you want to update a global variable, you shouldn’t have a local variable with the same name


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