vendredi 18 mai 2018

If statement returns undefined when checking if an array doesn't contain a word

I'm trying to log each name in the array except for the users, _id, etc. Doing if(!word === "users") works and logs the user entry as I would expect. I'm probably overlooking something trivial and apologize in advance. Thank you.

let arr = ["noun","nounoffensive","nounvulgar","adjective","verb","verbinformal","conjunction","exclamation","users","_id","word","createdAt","updatedAt","__v"]

arr.forEach((word)=>{
    if(!word === "users" || "_id" || "word" || "createdAt" || "updatedAt"){
        console.log(word)
    };
});

Aucun commentaire:

Enregistrer un commentaire