dimanche 22 septembre 2019

how can I optimize the following if else

I have the following if else block.

if (result.first && result.last){
output= "both present"
} else if (!result.first && result.last) {
output= "last present"
} else if (result.first && !result.last) {
output= "first present"
} else {
output = "none present"
}

The code looks clumsy. Is there any way I can optimize it.

Aucun commentaire:

Enregistrer un commentaire