Created
April 1, 2010 16:21
-
-
Save ishmaelahmed/352028 to your computer and use it in GitHub Desktop.
arrayScrub 2010-04-01 12:27:37 -0400
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* * | |
* 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