Created
November 29, 2012 20:28
-
-
Save greatseth/4171693 to your computer and use it in GitHub Desktop.
couchdb reduce function to find min value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function (key, values, rereduce) { | |
var min = Infinity | |
for (var i = 0; i < values.length; i++) { | |
if (typeof values[i] == 'number') { | |
max = Math.min(values[i], min) | |
} | |
} | |
return min | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you had to change "max" to "min"