Pizza.js


#1

Has anyone else noticed that the instructions in this exercise are wrong?

This step fails every time, and if you get the code after failing a number of times, there is no parameter for the getTax function. It’s called by the getSubtotal function inside.

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

Error message reads “Did you add a parameter to getTax?”

```

let orderCount = 0;

const takeOrder = (topping, crustType) => {
orderCount++;
console.log('Order: ’ + crustType + ’ pizza topped with ’ + topping);
};

takeOrder(‘mushroom’, ‘thin crust’);
takeOrder(‘spinach’, ‘whole wheat’);
takeOrder(‘pepperoni’, ‘brooklyn style’);

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

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

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

console.log(getSubTotal(orderCount));
console.log(getTax());
console.log(getTotal());


getTax Parameter
Functions | Return II
#2

Hi @alwaysl34rning,

There had been a discussion about this issue and reports had been sent. I wrote a rather lengthy reply there. If you have some time, you can go through it here.

To sum it up, the get code answer is following an older exercise which uses similar example (but different -it doesn’t require orderCount as parameter)
If you’re following this particular exercise’s instruction, getTax function taking parameter orderCount, then you should call getTax(orderCount) as argument inside getTotal function for the code to work properly:

Give them some time to look over this as there’re bugs/corrections for every new courses being rolled out.

Meanwhile, happy coding! :slight_smile:


#3

Thank you, I thought for sure I was misreading something the first few times or so I ran through the exercise. I came here and looked to see if anyone else had reported it, or noticed it, but somehow missed the thread you linked to.

I have no problem waiting while they fix things, and understand how it happens. I just wanted to make sure I was still sane…


#4

Hey I was wondering if anyone could explain why under the getSubTotal function the parameter is labeled as itemCount. That was really throwing me off through this section because I was thinking it would make more sense if you were multiplying the orderCount by 7.5 to get the sub total.


#5

@alwaysl34rning, you’re very much sane and great observation. :wink:

Due to the two versions of JS exercises using similar example (in which the older one going to be retired soon), I have to open up two lessons side by side before writing that comparison in my post.

So yeah that’s about the story. Happy Coding! Cheers :slight_smile:


#6

Hi @andrewnigro77, you can have orderCount as your parameter label (or any name for a parameter), but for the sake of passing exercises, it’s advisable to just follow the author’s instructions.

There’re too many ways you can write your code in real without the exercise’s constriction, the most important matter is to understand what is parameter, what is argument and the relationship between.

Cheers :slight_smile:


For more reading:


itemCount and orderCount
Isn't itemCount uneccessary?
#7

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