Learn JS | Functions Return (Pizza) itemCount / order Count / getSubTotal


Help please, I was able to get through the exercise, but my total is not appearing on the console. I’ve tried a few things and it either comes out as “undefined” or “0”


Sure but “trying a few things” is rarely the way to go, you have to be much more deliberate than that, to put things where they are supposed to be - doesn’t happen by accident.

Test both your functions by themselves. Ask yourself what they should be doing and then test for that. Narrow down the possible locations for your bugs.

For example, call getSubTotal with a few different numbers to see if you get the right results back. And call your takeOrder function to see if it increases your orderCount variable.

When you’ve figured out which particular action(s) fail, you can look for information on how to do that.

Make an argument for why something else should have been printed at the end, consider all the things that should have happened, and then go find out if they did (typically by printing out information as the code runs to see whether the right information is in the right place)


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