Error in Functions! - Pizza getTotal


I’m having trouble getting my getTotal function to return a value. Can anyone see what’s going on here? :pray:


let orderCount = 0;

const takeOrder = (topping, crustType) => {
itemCount= orderCount++;
console.log('Order: ’ + crustType + ’ pizza topped with ’ + topping);

takeOrder(‘mushroom’, ‘thin crust’);
takeOrder(‘spinach’, ‘whole wheat’);
takeOrder(‘pepperoni’, ‘brooklyn style’);

const getSubTotal= (itemCount) => {
return itemCount * 7.5;


const getTax= () => {
return getSubTotal * 0.06;

const getTotal= () => {
return getSubTotal + getTax;
/* It’s got to be some thing around this function*/



Order: thin crust pizza topped with mushroom
Order: whole wheat pizza topped with spinach
Order: brooklyn style pizza topped with pepperoni
[Function: getTotal]

^^^^ wtf?

Hi @jamesmacleod1990,

You need to make a function call with ( ) brackets and insert an argument, which is orderCount in it, like:

getSubTotal(orderCount) * ....

Same here, make two function calls with ( ) brackets, one for getSubTotal with an argument orderCount, the other one for getTax.

Finally, you still need to invoke/call the getTotal function with one pair of ( ) brackets. console.log(getTotal())

Change that it should be working.

Hope it helps :slight_smile:

Note: Notice you’re a new user here. Welcome! :smile:

It would be a kind gesture if you can go through the post here (Learn more) to edit/format your code. It definitely helps a lot if you have any more questions to ask in future.

Because of how Discourse (this forum) works, your code without proper format get twisted when I copy paste into my own environment. I would need to edit the code first before going through it.

So, it is much appreciated if you could edit/format code in the right way. That said, sorry for the long post and Happy Coding! Cheers! :slight_smile:


@codexthon Thank you!

1 Like

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