Write .inRange()
This commit is contained in:
parent
534819ee57
commit
10d7c5a686
1 changed files with 17 additions and 0 deletions
17
lodash/_.js
17
lodash/_.js
|
@ -4,5 +4,22 @@ let _ = {}
|
|||
|
||||
_.clamp = (num, lower, higher) => Math.min(Math.max(num, lower), higher)
|
||||
|
||||
/* ------------------------------------------------------------- inRange ---- */
|
||||
|
||||
_.inRange = function (num, start, end) {
|
||||
if (!end) {
|
||||
end = start
|
||||
start = 0
|
||||
}
|
||||
|
||||
if (start > end) {
|
||||
let s = start
|
||||
start = end
|
||||
end = s
|
||||
}
|
||||
|
||||
return start <= num && num < end
|
||||
}
|
||||
|
||||
// Do not write or modify code below this line.
|
||||
module.exports = _
|
||||
|
|
Loading…
Reference in a new issue