My function getTotal isn't working. What's wrong?


#1

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

My error message says:
expected [Function
expected [Function

I think it has something to do with the tax function, but I don’t know how to fix it.



var orderCount = 0;

function takeOrder(topping, crustType) {
  console.log('Order: ' + crustType + 
              ' pizza topped with ' + topping)
  orderCount = orderCount + 1;
}
function getSubTotal (itemCount) {
  return itemCount * 7.5;
}
function getTax(){
  return getSubTotal * 0.06;
}
function getTotal(){
  return getTax + getSubTotal;
}
takeOrder("sausage", "thin crust")
takeOrder("bacon", "stuffed crust")
takeOrder("pineapple", "no crust")

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



#2

We need to call the function.

return getSubTotal(orderCount) * 0.06;

Likewise, the function needs to be invoked with the orderCount variable as the argument.


#3

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