[Solved!] Intro to Functions Part 5 Error Message


#1

Hello everyone,
Before I begin, you should know that I am new to Codecademy, so this may be a simple problem.
On part 5 of Intro to Functions (Link), I keep getting an error message that says “Declare a variable named orderCount set equal to the number 0.”

My code:

let orderCount = 0;
const takeOrder = (topping, crustType) => {
  console.log(`Order: ${crustType} pizza topped with ${topping}.`);
  orderCount ++;
};
const getSubTotal = (itemCount) => {
  return itemCount * 7.5
}

takeOrder('mushrooms', "thin crust");
takeOrder("bacon", 'thick crust');
takeOrder("pineapples", 'no crust');
console.log(getSubTotal(orderCount))

I’m pretty sure that I declared the variable at the top, but it always shows that error. I’ve tried rewriting everything, refreshing the page, and exiting the lesson.

Solution:


#2

Your code works fine in the console. It could be something as simple as,

orderCount ++;

instead of,

orderCount++;

and/or,

return itemCount * 7.5

instead of,

return itemCount * 7.5;

#3

Thanks! It worked after that, and I also added a semicolon on the end of line 8.


#4

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