SHARE
TWEET

Untitled

a guest Oct 12th, 2015 1,584 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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top