Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

195
Visualizações
TypeError: x.include is not a function

I'm new on JS. In this code country is variable. Results can contain multiple answers at the same time 53,110,122 etc. And for example if I results have 68 I should get it but I get this error: Uncaught TypeError: country.include is not a function

var country         = 68;
if (country.includes(68)) {
var country         = 3;
}
if (country.includes(53)) {
var country         = 138;
}

In Python we can do this with if "x" in country . Any ideas for JS?

Note: If results have 68 and 53 same time, code working.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

includes is a function built-in for arrays. You can use this function with Arrays only or with "values of an Object" which are also an array. Before applying this function to your array which is "country", You have to confirm that whether it is array or not. for that we have a built-in function with Arrays as Array.isArray(country). This function returns true if the provided parameter is an array and vice versa. if(Array.isArray(country)) {... your checking conditions here} Here is simple exercise for include from w3school. Might be helpful. Thanks

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda