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

115
Vistas
Javascript if function makes other code not run

I have an if function that checks if the link doesn't break the rules:

const file = data.file.toLowerCase()
if(!file.startsWith('https://')
    || !file.endsWith('.gif')
    || !file.endsWith('.png')
    || !file.endsWith('.jpg')
    || !file.endsWith('mp4')
    || !file.endsWith('mp3')
    || !file.endsWith('.webm')
)
    return

This makes other code not run, even if the link doesn't break the rules. Can anyone help?

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

0

!file.endsWith('.gif') || !file.endsWith('.png') ...

This will always return true as a string can end with .gif (which matches !file.endsWith('.png') ), .png (which matches !file.endsWith('.gif')), or other things that will match both. Therefore the return will always run.

You may instead need &&

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