Avoid Let Variable Depending On Condition
Topic |
---|
๐งน Clean Code |
----------------- |
Having a
let
value is always a sign to change something. Consider using a function that returns the values into aconst
// problem:
let values;
if (a) {
values = xyz;
}
else {
values = abc;
}
// solution
const values = rebuildValues();
rebuildValues() {
if(a) {
return xyz;
}
else {
return abc;
}
};