Skip to content

Instantly share code, notes, and snippets.

@ishmaelahmed
Created April 1, 2010 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ishmaelahmed/352028 to your computer and use it in GitHub Desktop.
Save ishmaelahmed/352028 to your computer and use it in GitHub Desktop.
arrayScrub 2010-04-01 12:27:37 -0400
/* *
* Takes an array of objects and removes duplicate data on an interior poperty,
* and objects that have and empty testing poperty
* @params an array and a object param
* @returns array of unique objects, with no empty property value
* */
arrayScrub = function(array,param) {
var i, x, test, testArray = [array[0]];
for (i = 0; i < array.length; i++) {
test = 0;
for (x = 0; x < testArray.length; x++) {
if (array[i][param] == testArray[x][param]) {
test = 1;
}
}
if (test === 1) {
test = 0;
} else {
if(array[i][param] !== ''){
testArray.push(array[i]);
}
}
}
return testArray;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment