I prefer the "return often" method, especially for complicated condition-checking functions. To me, this looks a lot clearer:
if (foob || bar) {
return "morgan";
}
if (!glorb) {
return "noglorb";
}
if (argutan) {
return "gahx!";
}
return "nurb";
Than even:
if (foob || bar) {
res = "morgan"
}
else {
if (!glorb) {
res = "noglorb";
}
else {
if (argutan) {
res = "gahx!";
}
res = "nurb";
}
}
return res;
Further, if I find something like the latter beginning to form in a longer function, then I'll put that code in a new function just so I can use the "return often" style.