Created
August 18, 2016 21:59
-
-
Save layonthebeech/8a79e788df6a7f3bf092552b48b87872 to your computer and use it in GitHub Desktop.
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
Array.prototype.int = function (){ | |
return this.filter(function (x) { return typeof x == 'number' && x == ~~x }); | |
} | |
Array.prototype.even = function(){ | |
return this.int().filter(function (x) { return ~x & 1 }); | |
} | |
Array.prototype.odd = function(){ | |
return this.int().filter(function (x) { return x & 1 }); | |
} | |
Array.prototype.under = function(x){ | |
return this.int().filter(function (y) { return y < x }); | |
} | |
Array.prototype.over = function(x){ | |
return this.int().filter(function (y) { return y > x }); | |
} | |
Array.prototype.inRange = function(min,max){ | |
return this.int().filter(function (x) { return x >= min && x <= max }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment