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

105
Views
Use switch statement with multiple variables

I want to use switch statement with 2 variables, for example, a and b, something like this:

switch(a,b){
  case(1,1): // a = 1 and b = 1
    doSomething()
    break
  case(1,2): // a = 1 and b = 2
    doSomethingElse()
    break
  case(0,2): // a = 0 and b = 2
    doOtherthings()
    break
  default
    doNothing()
}

I know this code doesn't work, so is there any alternative way to do this?

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

0

You could use if statements instead.

if (a === 1 && b === 1) doSomething();
else if (a === 1 && b === 2) doSomethingElse();
else if (a === 0 && b === 2) doOtherthings();
else doNothing();
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!