Advertisement
olegsuv

Untitled

Sep 2nd, 2019
1,320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const a = [1, 3, 2, 4, 2, 4, 5] //1, 3, 5
  2. a.reduce((mapping, item, index, arr) => {
  3.   mapping[item] = !!mapping[item] ? ++mapping[item] : 1
  4.   return index === arr.length - 1 ? Object.keys(mapping).filter((e) => mapping[e] === 1) : mapping
  5. }, {})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement