Answers for "how to check if duplicate items in array and if yes take them out js"

1

javascript check if array has duplicates

function hasDuplicates(array) {
    return (new Set(array)).size !== array.length;
}
Posted by: Guest on July-28-2020
0

javascript check for duplicates in array

function checkIfDuplicateExists(w){
    return new Set(w).size !== w.length 
}

console.log(
    checkIfDuplicateExists(["a", "b", "c", "a"])
// true
);

console.log(
    checkIfDuplicateExists(["a", "b", "c"]))
//false
Posted by: Guest on September-16-2021

Code answers related to "how to check if duplicate items in array and if yes take them out js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language