Answers for "prevent adding the item twice in an array javascript"

0

prevent adding the item twice in an array javascript

var names = ["Mike","Matt","Nancy","Adam","Jenny","Nancy","Carl"];
var uniqueNames = [];
$.each(names, function(i, el){
if($.inArray(el, uniqueNames) === -1) uniqueNames.push(el);
});
Posted by: Guest on September-19-2020

Code answers related to "prevent adding the item twice in an array javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language