Reputation: 1973
I have names in an ignore list file called Ignore.json
[
"George",
"Carl"
]
The file is called ignore.json
In my program I am reading the file into the ignore variable
var ignore;
ignore = require("./Ignore.json");
Now I want to see if my array element is not in that list then if it is not in that list output the code.
I know how to check if an element is in an array like:
for (list in lists) {
if(lists[list].to.toLowerCase() in ignore){
But if I want to check that it is not "in" the list, what is the opposite of in in javascript?
Upvotes: 2
Views: 81
Reputation: 17048
var list, i;
for(i=0;i<lists.length;i++){
list = lists[i];
if(ignore.indexOf(lists[list].to.toLowerCase()) === -1){
// -1 indicates item was not in list
}
}
Upvotes: 3