Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const range1 = n => Array.from(Array(n).keys());
const range2 = (off, n) => Array.from(Array(n - off).keys()).map(i => i + off);
const range3 = (off, step, n) => Array.from(Array(Math.ceil((n - off) / step)).keys()).map(i => i * step + off);
const range = (...args) => args.length === 1 ? range1(...args) : args.length === 2 ? range2(...args) : range3(...args);
const repeat = (x, n) => Array.from(Array(n)).map(() => x);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.