Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

191
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda