3 ms·
Personally, I'd prefer to go with early return, I think. Depending on what the conditions mean semantically. It would be: if (conditionA && conditionB) {
by foota 7y ago
Personally, I'd prefer to go with early return, I think. Depending on what the conditions mean semantically.
It would be:
if (conditionA && conditionB) {
return "A & B"
}
if (conditionA) {
return "A"
} else {
return "Not A"
}
return "neither A nor B"
I think this comes from a general dislike of more than one else on an if and a dislike of nesting.