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

238
Vistas
Why console.log(10 < 14 < 50) is true but console.log(10 > 7 > 2) is false?

Why console.log(10 < 14 < 50) is true but console.log(10 > 7 > 2) is false? why does first give true and second gives false

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

0

It works that way:

First it calculate the left side (10 < 14) => it returns True, which is also 1.

Then it calculates the right side: (True < 50) which is (1 < 50) and this is also True.

On the other side, (10 > 7) => True = 1, but (True > 2) which is (1 > 2) is False.

If you'll try: console.log(10 < 14 == 1) you will see that it's also True.

about 4 years ago · Juan Pablo Isaza Denunciar

0

This is not how you would check an interval in JS.

Your code would be interpreted from left to right according to operator precedence. The comparison operators are binary operators, they take a left-hand expression and a right-hand expression

10 < 15 < 50
// To
true < 50 
// To
1 < 50

// And 
10 > 7 > 2
// To
true > 2 
// To
1 > 2

You should do:

console.log(14 < 10 && 14 <50)
//
console.log(7 < 10 && 7 > 2)
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