Last active
January 26, 2023 10:45
-
-
Save luislobo14rap/5df99454b4da413f2154caeda9aceccf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // between.js v1.1.1 | |
| function between(number, a, b, orEqual = false) { | |
| const min = Math.min(a, b), | |
| max = Math.max(a, b) | |
| if (orEqual == true) { | |
| return number >= min && number <= max | |
| } | |
| return number > min && number < max | |
| } | |
| Number.prototype.between = function(a, b, orEqual = false) { | |
| return between(this, a, b, orEqual) | |
| } | |
| String.prototype.between = function(a, b, orEqual = false) { | |
| return between(this, a, b, orEqual) | |
| } |
This file contains hidden or 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
| // between.min.js v1.1.1 | |
| function between(c,d,e,f=!1){let g=Math.min.apply(Math,[d,e]),h=Math.max.apply(Math,[d,e]);if(!0==f)return c>=g&&c<=h;return c>g&&c<h}Number.prototype.between=function(c,d,e=!1){return between(this,c,d,e)},String.prototype.between=function(c,d,e=!1){return between(this,c,d,e)}; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
between(1,0,2) // true
1 its between 0 and 2