I'be recently had a project in which I had to change some value based on a range of some other value...
so the code is pretty much like this:
if (temp <= 10) {
color = 'blue'
} else if (temp > 10 && temp >= 20) {
color = 'green';
} else if (temp > 20 && temp <= 30) {
color = 'yellow';
} else if (temp > 30) {
color = 'red'
}
is there any way to make this condition more "clean"?
Aucun commentaire:
Enregistrer un commentaire