I'm trying to test for a value within an array and act accordingly based on that result i.e., if the item does not exist in the array being tested then add it to the array. I've already spent way too much time on this, I could really use some help.
function FilterItems(attrName, attrValue, priceMin, priceMax) {
// check if item exists in filtered items
for (var i = 0; i < adlet.item.length; i++) {
if (adlet.item[i][attrName] == attrValue) {
var currentItem = adlet.item[i];
if (filteredItems.length > 0) {
// console.log(filteredItems.length);
for (var x = 0; x < filteredItems.length; x++) {
if (filteredItems[x].OMSID == currentItem.OMSID) {
// match found
break;
} else {
// match not found, add to filtered items.
filteredItems.push(currentItem);
}
}
} else {
filteredItems.push(adlet.item[i]);
// console.log(filteredItems.length);
}
}
}
filteredItemsand how is it defined? what isadletand how is it defined?