Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const nextId = ids => ids
- .sort((x, n) => x >= n ? 1 : -1)
- .reduce((acc, n, i, a) => acc !== null ? acc : (i === 0 && n > 0) ? 0 : ((typeof a[i+1] !== 'undefined') ? ((a[i+1] !== n && a[i+1]-1 !== n) ? n+1 : null) : n+1) , null)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement