Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

230
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!