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

109
Vistas
How to make every single value of array suitable in IF statement?

For example i have an array with 100 values, let it be a[1,2,3...100]
Can I create a if check that will be suitable for any value from the array?
like:

if(value === a[any index]){
//do smth
}

almost sure that it can be done but don't know how, can you help me with that?

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You can use forEach:

a.forEach(element => {
  if (value === element) {
    // do something
  }
});
about 4 years ago · Juan Pablo Isaza Denunciar

0

// for of
for (const item of a) {
  if (value === item) {

  }
}

// traditional for loop
for (let i = 0; i < a.length; i++) {
  if (value === array[i]) {

  }
}

// forEach
a.forEach(item => {
  if (value === array[i]) {

  }
});
about 4 years ago · Juan Pablo Isaza Denunciar

0

You should use the ES7 array.includes(). If it finds a given value in your array it will return a True boolean, else it will return False.

Example:

console.log([1,2,3].includes(2)) //True

console.log([1,2,3,4,5].includes(6)) //False

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