Javascript: Find duplicates in the array and delete from array.

Finding duplicates in array. Please go to groggyjava.

Deleting duplicates:

var duplicateCodes= [];
duplicateCodes.push(“ss”, “”, “ee”, “”,”ee”);  //inserting duplicates and some empty values.

duplicateCodes= duplicateCodes.filter(function(e){return e});  // removing empty values.
if(duplicateCodes.indexOf(“ee”) >= 0)  // checking if “ee” is already in the array
alert(“Please remove \n” + duplicateCodes.join(‘\n’));


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s