"expected [Function" error


#1

I keep getting “expected [function” error when using this code:

const getSubTotal = (itemCount) => {
  return itemCount * 7.5;
};
const getTax = () => {
  return getSubTotal(orderCount) * 0.06;
}
const getTotal = () => {
  return getSubTotal(orderCount) + getTax();
}
console.log(getSubTotal(orderCount));

so I used the get code option with the result below, but I cannot find any meaningful difference between my code above which errors, and the provided code below, which works. What am I missing?

const getSubTotal = (itemCount) => {
  return itemCount * 7.5;
};

const getTax = () => {
 return getSubTotal(orderCount) * 0.06; 
};

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

console.log(getSubTotal(orderCount));

#2

Welp. I see it now. missing semicolons after the closing curly braces for the second two functions.


#3

@bitsurfer74641,

I believe you’ve omitted some part of your code when posting the question. It is advisable to provide:

  • a link to the lesson in your question,
  • the error it throws
  • the full code you have come out with (with proper code formatting in your post, use the </> symbol to format the code, refer it here

for others to look and replicate your problem/situation to provide more help/explanation.

Currently as what can be seen, yes you’re right about that. However, I suspect that is not the real cause of the “expected [function” error, it could be further inspected if you can provide the full code and the link.


#4

thanks!
this was in Functions Return II

so I reset and started over again and I could not recreate the error.
I removed the semicolons and did not get the error again.
I even copied and pasted what I had saved from before and it still didn’t happen again. So, my best guess is it must be some quirk of the browser I’m using.


#5

Hi @bitsurfer74641,

Glad to hear it is resolved somehow. You’re welcome and happy coding! :slight_smile:


#6

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