Skip to content
Advertisement

Recursive function returns undefined

I have a function which calculates taxes.

JavaScript

I can’t see why it doesn’t stop the recursion.

Advertisement

Answer

In this arm of your function:

JavaScript

you are not returning a value from the function or setting returnTax. When you don’t return anything, the return value is undefined.

Perhaps, you want this:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement