_.random = function(min, max) {
if (max == null) {
max = min;
min = 0;
}
// if min is not integer, we can not get integer as return
return min + Math.floor(Math.random() * (max - min + 1));
}
_.random(5.1, 6) then we will get double not integer return. I think it is a bug because the doc told me I can get a random integer as return
min and max should probably be rounded before applying the formula
I created a pull request for this, see #2696
This issue can be closed. See https://github.com/jashkenas/underscore/pull/2696#issuecomment-343276407
Most helpful comment
I created a pull request for this, see #2696