Number.prototype.between = function(a,b){ return (a>b) ? this>=b && this<=a : this>=a && this<=b; } (7).between(5,10); // true (3).between(5,10); // false