Skip to content

Instantly share code, notes, and snippets.

@onosendi
Created January 2, 2022 19:48
Show Gist options
  • Save onosendi/4cd4304c175448c63d75c4c34b1b0e1a to your computer and use it in GitHub Desktop.
Save onosendi/4cd4304c175448c63d75c4c34b1b0e1a to your computer and use it in GitHub Desktop.
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