Created
June 12, 2018 17:19
-
-
Save wehrhaus/d1a0f91606724ab68419b20d53520fe7 to your computer and use it in GitHub Desktop.
Create a range of numbers
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* range(start, end) { | |
yield start; | |
if (start === end) return; | |
yield* range(start + 1, end); | |
} | |
const createRange = (a, b) => [...range(a, b)]; | |
// Example Usage: Create array of lowercase alphabet | |
const alphabet = createRange(97, 122).map(k => String.fromCharCode(k)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment