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

206
Views
¿Hay una forma más limpia de escribir esta parte del código, muchas declaraciones javascript if?

¿Hay una forma más limpia de escribir esta parte del código?
Siento que hay mucho más si las declaraciones
Lo más probable es que se pueda hacer usando una declaración de cambio, pero ¿cuán más limpio o más legible será?

 if (inflationArray.every((x) => x.value.length == 0)) { alert("Every field is empty"); return; } else if ( inflationArray[0].value.length == 0 && inflationArray[1].value.length != 0 && inflationArray[2].value.length == 0 ) { alert("You didn't type in any money value or inflation rate"); return; } else if ( inflationArray[0].value.length == 0 && inflationArray[1].value.length == 0 && inflationArray[2].value.length != 0 ) { alert("You didn't type in any money value or years"); return; } else if ( inflationArray[0].value.length != 0 && inflationArray[1].value.length == 0 && inflationArray[2].value.length == 0 ) { alert("You didn't type in any year or inflation rate"); return; } else if (inflationArray[0].value.length == 0) { alert("You didn't type in any money value"); return; } else if (inflationArray[1].value.length == 0) { alert("You didn't type in any year"); return; } else if (inflationArray[2].value.length == 0) { alert("You didn't type any inflation rate"); return; }
about 4 years ago · Santiago Trujillo
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!