java script how to avoid use the same element on a array code example
Example 1: how to remove duplicates in array in javascript
const numbers = [1 , 21, 21, 34 ,12 ,34 ,12];
const removeRepeatNumbers = array => [... new Set(array)]
removeRepeatNumbers(numbers) // [ 1, 21, 34, 12 ]
Example 2: deduplicate array javascript
function uniq(a) {
return Array.from(new Set(a));
}