I have an array which have all these values that I am trying to compare the var element.
var ALLITEMS = {
collection: ["item1", "item2", "item3", "item4", "item5", "item6", "item7", "item8"],
anotherCollection: ["anotheritem1", "anotheritem2", "anotheritem3", "anotheritem4"]
};
Now I am using this:
if(element == "item1" || element =="item2" || element =="item3" || element =="item4" || element =="item5" || element =="item6" || element =="item7") {
// do something
}
else {
// do nothing
}
Which works, but How can I shorten this to use the values inside the array ALLITEMS.collection because I have 32 items inside it.