Q:

Write a JavaScript program to filter out the non-unique values in an array

0

Write a JavaScript program to filter out the non-unique values in an array.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

const filter_Non_Unique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i));

console.log(filter_Non_Unique([1, 2, 2, 3, 4, 4, 5]));  
console.log(filter_Non_Unique([1, 2, 3, 4]));  

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now