DEV Community

austinmei5
austinmei5

Posted on

JS Range Function

const range = (start, end, step = 1) => {
let output = [];

if (typeof end === 'undefined') {
end = start;
start = 0;
}

for (let i = start; i < end; i += step) {
output.push(i);
}

return output;
};

Top comments (0)