Remove Duplicates from Array
const basket = ['๐', '๐', '๐', '๐', '๐', '๐'];
console.log(basket);
Using Set
// const fruits = [...new Set(basket)];
const fruits = Array.from(new Set(basket));
console.log(fruits);
Using Filter
const fruits = basket.filter(
(item, index, items) => items.indexOf(item) === index
);
console.log(fruits);
Using Reduce
const fruits = basket.reduce(
(unique, item) => (unique.includes(item) ? unique : [...unique, item]),
[]
);
console.log(fruits);