I have two arrays, one of the arrays holds all the unique values of another array. The second array holds the unique values of the duplicate values found of another array.
The following code below loops through the first array and checks to see if a value in that array index matches a value in the second array index for a duped item. If it does it will add an arrow before the item's text.
This doesn't seem to be working correctly and it's printing the first array, rather then checking for a duped item.
var aos = ["a","a","b","c","d","e","f","f","f","g","g","g","h","h","h"];
// Credits to the guy who helped me with this, internet w00t!
var duplicates = _.select(aos, function(val) {
var True = _.after(2, function() {
return true;
});
return _.any(aos, function(elem) {
return elem === val ? True() : false;
});
});
aos.sort();
aos = _.unique(aos);
var dennis = _.unique(duplicates);
if ($.inArray(aos[i], dennis)) {
console.log("CONTAINS!", dennis, aos[i]);
$("tr[number='" + i + "']").find("td:first-child").prepend("<img src='images/arrow.jpg' style='padding-right: 5px;'/>");
} else
console.log("no!");
Output:
no!
CONTAINS! ["a", "f", "g", "h"] b
CONTAINS! ["a", "f", "g", "h"] c
CONTAINS! ["a", "f", "g", "h"] d
CONTAINS! ["a", "f", "g", "h"] e
CONTAINS! ["a", "f", "g", "h"] f
CONTAINS! ["a", "f", "g", "h"] g
CONTAINS! ["a", "f", "g", "h"] h
What the output should be:
CONTAINS!
no!
no!
no!
no!
CONTAINS!
CONTAINS!
CONTAINS!
What could I possibly be doing wrong? If more information, or clarification is needed please let me know.