Skip to content

Instantly share code, notes, and snippets.

@RANUX
Created March 16, 2018 14:14
Show Gist options
  • Save RANUX/e88a41498ebc78079d4804ad30f2915d to your computer and use it in GitHub Desktop.
Save RANUX/e88a41498ebc78079d4804ad30f2915d to your computer and use it in GitHub Desktop.
Range function for JavaScript
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