Range (Min, Max) JS
function range(min, max) {
if (max === undefined && min !== undefined) {
return [...Array(min+1).keys()];
} else if (min !== undefined) {
return [...Array(max-min+1).keys()].map(elm => elm+min);
} else {
return;
}
}
range(5);// => [ 0, 1, 2, 3, 4, 5 ]
range(5,10);// => [ 5, 6, 7, 8, 9, 10 ]
Be funny