sum.js 161 Bytes Raw Blame History Permalink 1 2 3 4 5 6 7 8 module.exports = function sum(list, fn) { if (!list) { return 0 } var total = 0 for (var i=0; i<list.length; i++) { total += fn(list[i]) } return total }