1// Between any two numbers
2Math.floor(Math.random() * (max - min + 1)) + min;
3
4// Between 0 and max
5Math.floor(Math.random() * (max + 1));
6
7// Between 1 and max
8Math.floor(Math.random() * max) + 1;
1Number.prototype.between = function(a, b) {
2 var min = Math.min.apply(Math, [a, b]),
3 max = Math.max.apply(Math, [a, b]);
4 return this > min && this < max;
5};
6
7var windowSize = 550;
8
9console.log(windowSize.between(500, 600));