jeudi 15 août 2019

Is there a more efficient way to write multiple if else? [on hold]

I would need to match the average score to a letter grade. That means

if (90 < avg && avg < 100) {
     return 'A';
} 
// and so on until 'F', with 5 if-else statements 

That's a lot of repetition, and the ranges I'm matching to are of the same length. Is there a more efficient way to do this?

Aucun commentaire:

Enregistrer un commentaire