Skip to content

Instantly share code, notes, and snippets.

@webinista
Last active April 13, 2018 03:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webinista/6857aaec203d8b9e01b3c52235796d7d to your computer and use it in GitHub Desktop.
Save webinista/6857aaec203d8b9e01b3c52235796d7d to your computer and use it in GitHub Desktop.
Get a range of numbers that includes the min and max values. Integers only.
const range = (min, max) => {
const diff = max - min;
const spread = [...Array(diff).keys()].map(n => {return n + min});
spread.push(max);
return spread;
}
// Example usage
range(2,100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment