Skip to content

Instantly share code, notes, and snippets.

@jsangilve
Created November 5, 2015 14:47
Show Gist options
  • Save jsangilve/99db6615f692dc5c5545 to your computer and use it in GitHub Desktop.
Save jsangilve/99db6615f692dc5c5545 to your computer and use it in GitHub Desktop.
let range = function (start, end, step = 1) {
if (arguments.length === 1) {
([start, end] = [0, start]);
}
const length = Math.ceil((end - start) / step);
if (length <= 0) return [];
return Array.from(new Array(length), (elem, index) => start + (index * step));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment