Vassil_Iliev

unique-arr

Mar 22nd, 2022
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const arr = [2, 1, 3, 4, 6, 0, 0, 5, 7, 8, 10];
  2. let uniqueArr = arr.filter(function (item, index, arr) {
  3.     if (item != arr[index + 1]) {
  4.         return item;
  5.     }
  6. })
  7. console.log(uniqueArr)
Advertisement
Add Comment
Please, Sign In to add comment