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

97
Vistas
Cleaner/Simpler way to check if content in array has a value greater than 0

I have this array that combines different data and then if the array contains true, then I'm showing some text. So for example, even if video is the only one that has a length greater than 0 (true), and the rest are false, the text 'Click to go to list' will be still shown. Is there a clean/simplier way of doing this check?

const relatedLists = [
 videos.length > 0, // returns true or false
 interviews.length > 0,
 pdf.length > 0,
 audio.length > 0,
 book.length > 0,
];

Link={
 relatedList.includes(true) ? 'Click to go to list' : ''
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can check to see if atleast one length property in the array is truthy

Link={relatedList.some(v => !!v.length) ? 'Click to go to list' : ''}

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Some

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