my issue is that I need to filter a set of data...
my data carries..
var arrayWithDuplicates = [
{"licenseNum": "6", "state":"NV"},
{"licenseNum": "6", "state":"NV"},
{"licenseNum": "6", "state":"NV"},
{"licenseNum": "6", "state":"CA"},
{"licenseNum": "6", "state":"CA"},
{"licenseNum": "6", "state":"OR"},
{"licenseNum": "6", "state":"OR"},
{"licenseNum": "6", "state":"OR"},
{"licenseNum": "20", "state":"NV"},
{"licenseNum": "10", "state":"CA"},
{"licenseNum": "10", "state":"NV"},
{"licenseNum": "10", "state":"OR"},
{"licenseNum": "10", "state":"CA"}
];
new data should be
newdata = [6, 6, 6, 20, 10, 10, 10];
I've tried to do..
for (i = 0; i < arrayWithDuplicates .length; i++) {
if ((arrayWithDuplicates[i].licenseNum) === -1)) {
newdata .push({
licenseNum: arrayWithDuplicates[i].licenseNum,
state: arrayWithDuplicates[i].state
});
}
};
the result from what these, I get..
newdata = [6, 20, 10]
I've seen a lot of great examples, but it still doesn't resolve my issue. much appreciated.