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

170
Views
Why does 1 + 1 ? 1 : 0 + 1 return 1 instead of 3?

Why is 1 + 1 ? 1 : 0 + 1 equal to 1 and not 3? It's correct that it returns 3 if I wrap the expression 1 ? 1 : 0 with parentheses. But why is that needed? What is actually blocking the process to parse it correctly?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

It is evaluating (1 + 1) ? 1 : (0 + 1).

about 4 years ago · Juan Pablo Isaza Report

0

Because js first calculate 1 + 1 and after that check RESULT is true? if it is true, select 1.

1+1 is the truthy result

The falsy values in JavaScript are 0, 0n, null, undefined, false, NaN, and the empty string ""

enter image description here

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!