Exercise 5. Return

Hi guys,

I don’t understand why I’m getting 0 as the “orderCount” output when I increase the number every time the function “takeOrder” runs.


My code is here:

var orderCount = 0;
var totalPrice = 0;

function takeOrder(topping, crustType) {
  	console.log("Order: " + crustType + " pizza topped with " + topping);
  orderCount = orderCount++;

function getSubTotal (itemCount) {
	return itemCount * 7.5;

takeOrder("bacon", "thin crust");
takeOrder("pineapple", "thick crust");
takeOrder("cheese", "ultra massive crust");


Thanks for your feedback!

Cheers, Martin

Use orderCount++ rather than orderCount = orderCount++

The increment operator (++) automatically saves the new value in the variable.


lol @mb.martin.benes re:ulta massive crust

1 Like

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