Please help 6/7


#1


https://www.codecademy.com/courses/learn-javascript/lessons/functions/exercises/return-ii?action=lesson_resume


My code can't seem to get past the getTax function as it returns 0 as order count. Can any body help me find where I went wrong? Thanks!


var orderCount= 0;

function takeOrder(topping, crustType){
  return('Order:'+ crustType+ ' pizza topped with'+ topping);
  orderCount= orderCount + 1;
};

function getSubTotal(itemCount){
  return(itemCount * 7.5);
};

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

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

takeOrder('sausage','Thin crust');
takeOrder('Pepperoni', 'Deep dish');
takeOrder('mushroom', 'Chicago style');

console.log('Your bill comes to '+ getSubTotal(orderCount) + '.');
console.log('The total with tax is '+ getTotal()+'.');


#2

Hi crim5onx,

In the takeOrder function block write the return statement after orderCount = orderCount + 1. Because return function stops the execution of a function and returns a value from that function. So in a function block if you write anything after a return statement it doesn't get executed. May be that's why orderCount is returned as 0.


#3

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