assign variables: give a reason for the assignment

The variable assignment wasn't necessary. This gives a reason to have it there
This commit is contained in:
Eddie Monge
2016-01-04 14:10:48 -08:00
parent 90e6cd1c98
commit 397f5bbd14

View File

@@ -1102,45 +1102,36 @@ Other Style Guides
> Why? `let` and `const` are block scoped and not function scoped.
```javascript
// good
function () {
test();
console.log('doing stuff..');
//..other stuff..
// bad - unnecessary function call
function checkName(hasName) {
const name = getName();
if (hasName === 'test') {
return false;
}
if (name === 'test') {
this.setName('');
return false;
}
return name;
}
// bad - unnecessary function call
function (hasName) {
const name = getName();
if (!hasName) {
return false;
}
this.setFirstName(name);
return true;
}
// good
function (hasName) {
if (!hasName) {
function checkName(hasName) {
if (hasName === 'test') {
return false;
}
const name = getName();
this.setFirstName(name);
return true;
if (name === 'test') {
this.setName('');
return false;
}
return name;
}
```