Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 391 Bytes

prefer-multiple-returns-to-let.md

File metadata and controls

25 lines (17 loc) · 391 Bytes

Prefer:

if (condition) {
  return "something else";
}

return "a thing"

Instead of:

let myValue = "a thing";

if (isConditionTrue) {
  myValue = "something else";
}

return myValue;

Rationale

This improves maintainability because the reader never need ask/answer the question "under what circumstances might myValue be re-assigned to a different value?"