Advertisement
Guest User

Untitled

a guest
Oct 12th, 2015
1,839
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const nextId = ids => ids
  2.     .sort((x, n) => x >= n ? 1 : -1)
  3.     .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