-1

So I have an array where it stores the users language, like so:

let language = []
    
     var Lang = "it"
     language.push(Lang)

and I do this multiple times with different languages.

I basically want to go through the array, and check:

The array would look like this:

language = ["en", "it", "es"]

then I want to check all of the values in the array, and if none of them are en, then log.

if (Lang != "en") {
   console.log("no en")
}

I think I have to use mapping, I could be wrong. I'm not sure how to do this?

Gianluca
  • 900
  • 8
  • 27

1 Answers1

-1

Use includes:

let language = ["en", "it", "es"];
if (language.includes("en"))
  console.log("have it");
Omri Attiya
  • 3,917
  • 3
  • 19
  • 35