Question : Unique Elements
Answered by : rich-rhinoceros-i9ndqct06v35
const getUnique = (arr) => [...new Set(arr)];
// Testing
const arr = [1, 1, 2, 3, 3, 4, 4, 4, 5, 5];
console.log(getUnique(arr));
Source : https://dev.to/ruppysuppy/7-killer-one-liners-in-javascript-one | Last Update : Thu, 21 Apr 22
Question : Unique Elements
Answered by : david-k
const getUnique = (arr) => [...new Set(arr)];
// Testing
const arr = [1, 1, 2, 3, 3, 4, 4, 4, 5, 5];
console.log(getUnique(arr));
Source : https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf | Last Update : Fri, 07 Oct 22