Functions: Return

I don’t get the last one.

Can someone explain it to me?

Hi, @rattlecage26 ,

In that final statement, you multiplied the getSubTotal function, itself, by a number instead of multiplying the result of calling the function by a number.

console.log(getSubTotal * orderCount)

The result is NaN, which is not a number.

EDIT (December 5, 2016): Note that the instructions ask the user to call the getSubTotal function, but do not ask to have the result multiplied by anything.

It is best to post questions regarding Codecademy exercises within the discussion area specifically devoted to the series that contains that exercise, and to post a link to the exercise. That enables users who hope to offer help to find the exercise.


A post was split to a new topic: Hope some one can help me for below questions

I don’t follow you in this sentence “you multiplied the getSubTotal function, itself, by a number instead of multiplying the result of calling the function by a number.” Is there another way you could explain it?

Where I’m having trouble is understanding is:

  1. Why do you pass in orderCount instead of itemCount?
  2. Come to think of it, why did we create a var for orderCount and not for itemCount? itemCount just suddenly appears as an argument for getSubTotal? (Maybe this was in the previous Return lesson, but it’s been a few weeks.)

I know from the hint that the right answer is to pass orderCount in getSubTotal, but I want to understand why before I move on.

1 Like

Hi @stellapygmy,

The code contains a function named getSubTotal. Whenever that function is called, it should be passed a numerical value, as an argument, and within the function, the value of that argument is represented by the name itemCount. As a function parameter, itemCount is a local variable that is only recognized within the getSubTotal function.

In this statement the original poster attempted to multiply the function name, getSubTotal, by the value of the variable orderCount

console.log(getSubTotal * orderCount)

What is really needed is for the result of calling the function to be multiplied by orderCount. In the function call, orderCount should be passed as an argument, as follows …


Then, as the function executes, the value of orderCount will be represented by itemCount within the function. The returned result will get displayed in the console.


Thanks, @appylpye! The next module (About global vs. functional variables) also helped me understand what was going on, too. Thank you!

Awesome, enjoy the rest of the course. :smile:

1 Like