Created
January 2, 2022 19:48
-
-
Save onosendi/4cd4304c175448c63d75c4c34b1b0e1a 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
function isInRange(number, range) { | |
const [start, end] = range.split('-').map((r) => Number(r)); | |
return number >= start && number <= end; | |
} | |
console.log(isInRange(5, '0-10')); | |
// true | |
console.log(isInRange(11, '0-10')); | |
// false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment