mardi 8 octobre 2019

Easier way for multiple if-else tests

I have a string and I want to execute if statement if string value matches given set of words(say ape,eat,sleep,mango........)

I can do:-

if(name=="ape" || name=="eat".............)

Is there any easier method to do this?

I want to use if-else ONLY.

Aucun commentaire:

Enregistrer un commentaire