Stuck on functions exercise 5


I am not getting a correct order count. it should be 3 orders multiplies by 7.5, but what i get is just 0. I am not really getting what I am doing wrong. The instructions do seem a tad confusing regarding calling the order count function/ Can someone please help?

var orderCount = 0;

function getSubTotal(itemCount){
  return itemCount * 7.5;

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

takeOrder("mushrooms", "thin");
takeOrder("bell peppers", "thick");
takeOrder("onions", "stuffed");



Delete the var ,it makes orderCount a local variable.
var orderCount = orderCount + 1;

just write,
orderCount = orderCount + 1
here It modifies global variable when you call takeOrder() funtion!

I hope it helps! :slight_smile:


Yes that works! Thanks a lot greentreemee


You're welcome! Keep up the good work! :slight_smile:


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