Skip to content

Instantly share code, notes, and snippets.

@vv13
Created Feb 8, 2022
Embed
What would you like to do?
no lodash
// follow python range func.
function range(start, end = null, step = 1) {
if (end === null) return Array(start).fill().map((_, index) => index)
const result = []
for (let i = start; step > 0 ? i < end : i > end; i += step || 1) {
result.push(i)
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment