Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const result = arr.reduce((acc, val) => {
  2.   if (acc.includes(val)) {
  3.     const otherDuplicateIdx = acc.indexOf(val);
  4.     acc[otherDuplicateIdx] = 3;
  5.     return [...acc, 3];
  6.   } else {
  7.     return [...acc, val];
  8.   }
  9. }, []);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement