A clever and easy way to obtain distinct values from an array is by converting the array to a Set
const removeDuplicates = (arr) => [...new Set(arr)];
removeDuplicates ([1, 2, 3, 3, 4, 4, 5, 5, 6, 7, 11, 11, 14, 14, 14]) ;
Thank you for reading, have a nice day!
- Follow me on Twitter - @codewithsnowbit
- Subscribe me on YouTube - Code With SnowBit
Top comments (0)