Last active
April 13, 2018 03:51
-
-
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.
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
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