My cost of pizza is 0. What's wrong? (Functions 5. Return)


Hey there, I've followed (and apparently completed all the boxes) on step 5. Return, but my result shows a pizza sub-total of 0. Is this not solved until later, or am I doing something wrong? I can't wrap my head around where this problem is for some strange reason, and don't want to continue if I'm uncertain. I change the bottom line from console.log(getSubTotal(orderCount)); to console.log(getSubTotal(3)); but that avoids the whole point of the program counting the orders.

My code returns:
Order: thin crust pizza topped with bacon
Order: regular crust pizza topped with pepperoni
Order: whole grain crust pizza topped with pinapple
0 <------------ this should be 22.5

var orderCount = 0;
function takeOrder(topping, crustType) {
  return ('Order: ' + crustType + ' crust pizza topped with ' + topping);
  orderCount = (orderCount + 1);
console.log(takeOrder('pinapple','whole grain'));

function getSubTotal(itemCount) {
  return itemCount * 7.5;


What actions are being carried out in your code? Should that be resulting in a non-zero cost?

What would need to happen for the cost to be non-zero?

Can you find out if those things are being done somehow?


Try changing the "return" in "return('Order: ' + crustType + ' crust pizza topped with ' + topping);" to "console.log"

Return takes the result and returns it back to whatever called it (without printing), and console.log would print your result.

Hope that works/helps.


Okay, thank you! I changed it to console.log and it works. I also removed the console.log before every takeOrder

I guess I assumed I needed to get console.log out of my takeOrder function because of this first line of the section stating:

"Using console.log as the result of a function isn't the best use of a function. "

Much appreciated. Now I can start progressing further.


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