0

//My array

const array[1,2,3,4,4,5,5]

//expected answer

const newArray[1,2,3]

Reminder i dont want to keep number 4 or 5 in the array i want to remove both

  • 1
    https://stackoverflow.com/questions/1960473/get-all-unique-values-in-a-javascript-array-remove-duplicates this may help – Cameron Jul 28 '21 at 19:05
  • `const newArray = array.filter((value, index, arr) => arr.indexOf(value) === index);` this should work. OR `const newArray = [...new Set(array)];` – K450 Jul 28 '21 at 19:09
  • 1
    Regarding your edit, [this question](https://stackoverflow.com/questions/43505967/completely-removing-duplicate-items-from-an-array) is an _exact_ duplicate of yours. – Ivar Jul 28 '21 at 19:15
  • 1
    It may be worth pointing out that only the last linked question (https://stackoverflow.com/questions/43505967/completely-removing-duplicate-items-from-an-array) is a duplicate of yours, but that is an exact duplicate, even the sample array is the same. – tevemadar Jul 28 '21 at 19:23

0 Answers0