getTotal not logging


#1

Learning JavaScript - Returns II

I’ve fallen at the final hurdle, my getTotal function only returns “NaN”. I’ve messed about with it and can’t get it to return a number.

Any help would be great, thanks.

var orderCount = 0;

function takeOrder (crustType, topping1, topping2) {
  orderCount = orderCount +1;
  return crustType + " Pizza with "+ topping1+ " and " +topping2;
}

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

function getTax () {
  return getSubTotal * 0.6;
}

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

console.log(takeOrder("Thin", "Bacon", "Cheese"));
console.log(takeOrder("Thin", "Ham", "Cheese"));
console.log(getSubTotal(orderCount));
console.log(getTotal());

#2

in getTax() the way you have getSubTotal written in the return statement is incorrect. you need to add the parentheses with the parameter to it


#3

Yeah that fixed it, thanks a lot. I’ve now learned that when calling functions with arguments in other functions you need the ref the arguments always.

Thanks again.


#4

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