JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
JavaScript
var data = [
[1, "07/28/2014"],
[2, "07/29/2014"],
[3, "07/28/2014"],
[4, "07/30/2014"],
[5, "07/28/2014"],
];
var data2 = [
[1, "07/28/2014"],
[2, "07/29/2014"],
[3, "07/29/2014"],
[4, "07/29/2014"],
[5, "07/29/2014"],
];
function removeDuplicates(Array){
this._newArray = [];
this.numberOfDuplicates = 0;
this.listDuplicates = [];
//Remove Duplicates
for(i=0;i<Array.length;i++){
for(j=0;j<Array.length;j++){
if(!Array[i][1]) //skip the current loop if index is empty
break;
if(Array[i][1]==Array[j][1] && i!=j){
this.listDuplicates.push(Array[j]);
Array[j]=0;
this.numberOfDuplicates+=1; //increase counter for dupes
}
}
}
//Recreate Array
this.newArray = function(){
for(i=0;i<Array.length;i++){
if(Array[i])
this._newArray.push(Array[i]);
}
return this._newArray;
}
}
var data = new removeDuplicates(data);
console.log(data.newArray());
console.log(data.numberOfDuplicates + " Duplicates");
console.log(data.listDuplicates);
console.log("\n");
var data2 = new removeDuplicates(data2);
console.log(data2.newArray());
console.log(data2.numberOfDuplicates + " Duplicates");
console.log(data2.listDuplicates);