5/7 - What is wrong with my code?


#1

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));

#2

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
22.5

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


#3

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?


#4

Hey @mzmint s the challenge passing for you?


#5

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;


#6

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


#7

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.


#8

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