Created
March 16, 2018 14:14
-
-
Save RANUX/e88a41498ebc78079d4804ad30f2915d to your computer and use it in GitHub Desktop.
Range function for JavaScript
This file contains hidden or 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, step=1) { | |
let i = start; | |
while ( i < end ) { | |
yield i; | |
i += step; | |
} | |
} | |
[...range(0,5)].map(x => x*2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment