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

220
Views
Is there a shorter, smarter way to deal with a long list of conditions in an if statement?

For example: I have a grid where each square is identified by a value denoting row and column, eg: 32 is in the 3rd column and 2nd row. Nearby locations would be squares 31, 33, 41, 42, 43, 21, 22, 23.

if (main.location === player.location - 1 || 
main.location === player.location + 1 || 
main.location === player.location - 9 || 
main.location === player.location + 9 || 
main.location === player.location - 10 || 
main.location === player.location + 10 || 
main.location === player.location - 11 || 
main.location === player.location + 11) {
    console.log("player is nearby");
    }
about 4 years ago · Santiago Gelvez
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!