I get 0 in exercise 5 on functions


#1

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-javascript-functions/lessons/functions/exercises/return?action=lesson_resume&course_redirect=introduction-to-javascript

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
There are no error messages and I passed all the exercises. The problem is I get 0 where I should be getting 22.5. I tried changing a few things in the code but it still does not work.

let orderCount = 0
const takeOrder = (topping, crustType) => {
  console.log('Order: ' + crustType + ' pizza topped with ' + topping);
orderCount = orderCount++;
}
const getSubTotal = (orderCount) => {
  return(orderCount * 7.5);
}
takeOrder('mushrooms', 'thin');
takeOrder('ham', 'thick');
takeOrder('bacon', 'medium');
console.log(getSubTotal(orderCount));

https://www.codecademy.com/courses/learn-javascript-functions/lessons/functions/exercises/return?action=lesson_resume&course_redirect=introduction-to-javascript


#2

here:

orderCount = orderCount++;

orderCount++ is a shorthand for orderCount = orderCount + 1, in other words you wrote:

orderCount = orderCount = orderCount + 1

that doesn’t look right


#3

Thank you. I changed it to:
orderCount += 1;
and it works. Although I tried it first when I was doing the exercise and I did not pass it. It was the Codecademy’s hint that suggested: orderCount = orderCount++;.
Or I misspelled something, which seems more plausible.


#4

i can’t see the exercise yet, i have to retake the course (haven’t gotten to it yet)

i do not hope the hit suggested that, just orderCount++ is viable, but orderCount = orderCount++ isn’t


#5

I checked and there it is, the infamous hint:


#6

i will report it as a bug


#7

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