Your function isn't returning a numerical value. What happens is that at compile time (at the time that the machine compiles the javascript code and processes the output), all functions are executed. Since your function is calling a function and outputting the data to screen (instead of returning the value to the invoker), the function gets resolved to it's output, and so the number "19" gets written to the screen. The original output gets printed, where you called your function. And since you didn't return a value, the value that you make reference to is undefined.
|