Hacker News new | ask | show | jobs
by foota 2549 days 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.