Solved all exercices correct but code returns zero


#1

Hello,

i followed the instructions as i was told but somehow my code only returns 0
where did i go wrong?



var orderCount = 0

function takeOrder( topping, crustType )	{
orderCount + 1
console.log('Order: pizza topped with ' + topping + ' and ' + crustType + ' Crust');
}

takeOrder('Cheese','Cross');
takeOrder('Salami','Cheese');
takeOrder('Bacon','Soft');

function getSubTotal(itemCount){
 			return itemCount * 7.5
}

function getTax()	{
  return getSubTotal(orderCount) * 0.06;
}

function getTotal(){
  return getSubTotal(orderCount) + getTax();
}


console.log(getSubTotal(orderCount));
console.log(getTotal());



#2

it’s on this line here: orderCount + 1

You have to make it orderCount += 1, that way it actually saves the change to the variable itself. Otherwise, it just sees it as an arbitrary mathematical operation, in this case orderCount + 1 is equivalent to 0 + 1, and doesn’t actually do anything.


#3

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