Problem with lesson 6 return II


In this chapter I was doing okay until the last part, where it tells me to get the total by calling the function inside a console log statement, but every time I do, I don’t get the total. Here is what I wrote:

var orderCount = 0
function takeOrder(topping, crustType){
  console.log('Order: '+ crustType +' pizza topped with '+ topping);
  orderCount = orderCount + 1;
function getSubtotal(itemCount){
  return itemCount * 7.5;
function getTax(){
  return getSubtotal(orderCount) * 0.06
function getTotal(){
  return getSubtotal(orderCount) + getTax

takeOrder('bacon', 'thin crust')
takeOrder('ham', 'cheese crust')
takeOrder('pepperoni', 'thin crust')

And here is what I got in the console:
Order: thin crust pizza topped with bacon
Order: cheese crust pizza topped with ham
Order: thin crust pizza topped with pepperoni
[Function: getTotal]


getTotal is a function, calling a function requires parentheses, here:


you call the getSubtotal function correctly, and you use parentheses, yet on the line below, you don’t call the function correctly, one function has a parameter, the other doesn’t, does that confuse you? In both cases, calling the function requires parentheses


Oh, yeah, I forgot about that lol. But still, when I put them, this appears in the console:
Order: thin crust pizza topped with bacon
Order: cheese crust pizza topped with ham
Order: thin crust pizza topped with pepperoni
22.5function getTax(){
return getSubtotal(orderCount) * 0.06


difficult to say what caused the problem without seeing what changes you made to the code




I think I see the problem but I am still learning and don’t really understand why/how it actually works yet.

I have:
const getTax = (orderCount) => {

where you have:
function getTax=() {

So you probably need to add orderCount inside the parentheses. Does that fix it? And if so, do you know why it needs the orderCount parameter there and not in the getTotal function? I think it’s because the orderCount’s returned value has just been updated to equal the price (the sub total, that is) in the previous code block (the getSubTotal function).


In your getTotal() function you have to pass the orderCount parameter to the getTax() aswell like so:

const getTotal = () => {
   return getSubTotal(orderCount) + getTax(orderCount);

When you call getTotal() you need to add parantheses because it’s a function.





Hello, kameron.kant

Your code needs only two improvements. Line 13 and 20 of your code: getTax and getTotal are missing paretheses:

getTax() inside your getTotal() function

Fix those and your code will work :slight_smile:


Hello, macurious.

getTax() doesn’t have any parameters, so it doesn’t take any arguments. Leave it blank and you’ll get the same result. Cheers :slight_smile:


It turns out there seem to be two different versions of this course.


Thank you for the clarification! I had this first course where it says it takes the parameter orderCount.
Very confusing! I thought the entire time that i didn’t understand the code. :slightly_frowning_face:


Thanks, got it now. :+1:t3:


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