相关疑难解决方法(0)

递归函数返回undefined

我有一个计算税收的功能.

function taxes(tax, taxWage) 
{
    var minWage = firstTier; //defined as a global variable
    if (taxWage > minWage) 
    {
        \\calculates tax recursively calling two other functions difference() and taxStep() 
        tax = tax + difference(taxWage) * taxStep(taxWage);
        var newSalary = taxWage - difference(taxWage);
        taxes(tax, newSalary); 
    }
    else 
    {
        returnTax = tax + taxWage * taxStep(taxWage);
        return returnTax;
    }
} 
Run Code Online (Sandbox Code Playgroud)

我不明白为什么它不会停止递归.

javascript recursion return

6
推荐指数
2
解决办法
4706
查看次数

标签 统计

javascript ×1

recursion ×1

return ×1