I need to find the most succinct way to return one of three values based on two arguments. I think a switch statement is the most succinct but please suggest alternatives.
I have two arguments, type and action
If action == 'close' then the returned result should always be 'Hide'
If action == open then more checks are needed
If action == 'open' && type == 'flight' return show more flights
If action == 'open' && type == 'protection' return show protections
What's the most succinct way to do this without involving multiple nested if statements? This whole statement is already inside another if statement called by a ternary so I don't really want to add more.
Aucun commentaire:
Enregistrer un commentaire