Code coverage report for financial/npv.js

Statements: 100% (8 / 8)      Branches: 100% (0 / 0)      Functions: 100% (3 / 3)      Lines: 100% (7 / 7)     

All files » financial/ » npv.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 231               1 6     6 37     6     1      
define(function () {
 
 
    /**
     * Net present value
     * http://en.wikipedia.org/wiki/Net_present_value
     * @version 0.1.0 (2011/12/30)
     */
    function npv(discountRate, values) {
        var val = 0,
            n = values.length;
 
        while (n--) {
            val += values[n] / Math.pow(1 + discountRate, n + 1);
        }
 
        return val;
    }
 
    return npv;
 
});