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

141
Views
Confusion over else...if vs regular if

I am a brand new programming hobbyist. I decided to start with JavaScript because I am interested in Web Development. Working through some classes I have encountered something that really confuses me. What is the purpose of "else...if" when it seems that multiple "ifs" do the same thing. I've really tried to find this answer before I posted here. I've worked out several tests in the Chrome console. Thank You in advance.

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

0

It makes a difference when multiple conditions might hold. For example:

if (x) { do thing 1 }
if (y) { do thing 2 }

will do both thing 1 and thing 2 if x and y are both true. But

if (x) { do thing 1 }
else if (y) { do thing 2 }

will do only thing 1 if x is true, even if y is also true. It will do y only if y is true and x is false.

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!