Return II Buggin - Wasn't sure how to simply report without this visual


#1

I wasn’t sure how to simply report this using the report a bug section without the visual. I did however try.
When following the instructions I passed the lesson but the totals calculated to zero. When I changed the code for orderCount = orderCount++ to only orderCount++ it calculated & console.logged correctly.



var orderCount = 0;
const takeOrder = (topping, crustType) => {
  console.log('Order: ' + crustType + ' pizza topped with ' + topping);
  orderCount = orderCount++;
};
const getSubTotal = (itemCount) => {
  return itemCount * 7.5;
};
const getTax = () => {
  return getSubTotal(orderCount) * 0.06;
};
const getTotal = () => {
  return getSubTotal(orderCount)+ getTax();
};
takeOrder('mushroom', 'thin crust');
takeOrder('spinach', 'whole wheat');
takeOrder('pepperoni', 'brooklyn style');
console.log(getSubTotal(orderCount));
console.log(getTotal());



#2

Isn’t that how the function is supposed to work? orderCount ++; is the same as orderCount += orderCount;

at least i think that’s how it works if I remember correctly…I might also be mixing up some python syntax… i don’t… know… anymore… I’m more confused on why the instructions said getTax(); should take a parameter when an argument is never passed… getTotal takes no parameter which looks like getTotal(); but getTax takes a parameter which means getTax(something); right? that something is never used… i’m confused by that.


#3

Not sure bumbard, still learning. I only wanted to point out that the instructions didn’t result in the the desired calculation but allowed completion of the lesson. I agree that some of the syntax can be confusing, especially with my current limited knowledge.


#4

The hint seems to be incorrect. According to the documentation, using ++ to increment must go before the variable name for it to return the value after incrementing.

let x = 0;

x = x++;
//returns 0 because it's the value before incrementing

x = ++x;
//returns 1 because it's the value after incrementing

#5

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