5/7 - What is wrong with my code?

On the last line of your program, after the takeOrder function calls, call the getSubTotal function inside a console.log statement.

getSubTotal has a parameter that represents the amount of items ordered. Pass in the orderCount as an argument when making the function call.

var orderCount = 0;

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

function getSubTotal (itemCount) {
  return itemCount * 7.5;

takeOrder("bacon", "thin");
takeOrder("bacon", "thick");
takeOrder("bacon", "normal");

console.log (getSubTotal(orderCount));

nothing, so long as this is the expected output:

Order: thin crust pizza topped with bacon
Order: thick crust pizza topped with bacon
Order: normal crust pizza topped with bacon

I know JavaScript, but haven’t taken the tutorial.

orderCount = orderCount +1; // put a space between i.e. orderCount + 1;
I noticed that when I didn’t put the spaces exactly like the program asked me to, I would get the same error code. I was stuck on this exercise today. It looks correct besides the spacing and semicolons after the curly brackets. Can anyone verify?

Hey @mzmint s the challenge passing for you?

I’m not exactly sure what you mean? I did one more thing different from the code above. I switched orderCount and console.log lines. I put console.log line first then the orderCount line.

console.log("Order: " + crustType + " crust pizza topped with " + topping);
orderCount = orderCount +1;

Oh ok so within that codeblock switching between those two lines shouldnt effect the result :slight_smile:

I figured that much. let me know if you are still stuck on this. I’m finished it, but I’m a bit confused, so I posted up something on the board.

1 Like

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