Fixed bugs pointed out by @kingdavidmartins

This commit is contained in:
Arjun Mahishi
2017-12-20 23:42:20 +05:30
parent a968a3cc28
commit 8873c54304

View File

@ -5,7 +5,10 @@ Checks if the given number falls in the given range.
`end` is an optional parameter. If `end` is not given, the range is considered from `0` to `start`.
```js
const inRange = (n, start, end=null) => (end == null) ? (n>=0 && n<=start) : (n>=start && n<=end);
const inRange = (n, start, end=null) => {
if(end && start > end) end = [start, start=end][0]
return (end == null) ? (n>=0 && n<start) : (n>=start && n<end);
}
// inRange(3, 2, 5) -> true
// inRange(3, 4) -> true