I am trying to find an item in an array. I get only -1 for my variable a
, so the item was not found in my array, but the item is definitely in array.
var sortiment = [];
var geschmack = [];
var kategorie = [];
function filterOptions(eigenschaft, filter){
inhalt = filter + " = " + eigenschaft;
console.log(inhalt);
console.log(sortiment[0]);
a = sortiment.indexOf(inhalt);
console.log(a);
switch(filter) {
case "sortiment":
sortiment.push([inhalt]);
break;
case "geschmack":
geschmack.push([inhalt]);
break;
case "kategorie":
kategorie.push([inhalt]);
break;
default:
console.log("FAIL");
}
}
In case the item is found, I want not to add it to the array.