This Learn Javascript bug will make you cringe, then laugh so hard


#1

I'm supposed to 'Inside the takeOrder function, set orderCount equal to orderCount plus 1, so that each time the takeOrder function runs, 1 is added to the orderCount.', but this code looks okay. Buuut it doesn't work.
The error returns: Did you add one to the orderCount whenever the takeOrder function runs?

var orderCount = 0;
function takeOrder(topping, crustType) {
console.log("Order: "+crustType+" pizza topped with "+topping+"");
orderCount += 1;
}

takeOrder("pepperoni", "thin crust");
takeOrder("pep", "thick crust");
takeOrder("wtf", "ba'al");

I actually finished the Javascript course before discovering that this course exists, but went back to cover new material.


#2

Okay, I fixed it myself. My new code is even more surprising:

var orderCount = 0;
function takeOrder(topping, crustType, orderCount) {
orderCount = orderCount + 1;
console.log("Order: "+crustType+" pizza topped with "+topping+"");

}

takeOrder("pepperoni", "thin crust");
takeOrder("pep", "thick crust");
takeOrder("wtf", "ba'al");