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

323
Views
Why does my first expression evaluate to false and my second one evaluates to true? Shouldn't they be the same?

Lets say that error.message = 'user_not_found'

    console.log(
        error.message === 'user_not_found' || error.message === 'password_missing_onboarding_incomplete'
            ? false
            : true
    );

This returns false and is working good.

I tried shortening this to:

console.log(error.message !== 'user_not_found' || error.message !== 'password_missing_onboarding_incomplete');

Which I assumed would work the same, but instead it returned true. Am I missing something?

about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

The negative of

error.message === 'user_not_found' || error.message === 'password_missing_onboarding_incomplete'

is

error.message !== 'user_not_found' && error.message !== 'password_missing_onboarding_incomplete'
about 4 years ago · Santiago Gelvez Report

0

just group the logic and then negate it

console.log(!(error.message === 'user_not_found' || error.message === 'password_missing_onboarding_incomplete'));

if it was full it would be

let result = !(
    error.message === 'user_not_found' ||
    error.message === 'password_missing_onboarding_incomplete'
);
about 4 years ago · Santiago Gelvez 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!