From 397f5bbd14d2118c0183b6a3fe5ceda6b1c81832 Mon Sep 17 00:00:00 2001 From: Eddie Monge Date: Mon, 4 Jan 2016 14:10:48 -0800 Subject: [PATCH] assign variables: give a reason for the assignment The variable assignment wasn't necessary. This gives a reason to have it there --- README.md | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 7bcf0ef8d7..e7b3e37227 100644 --- a/README.md +++ b/README.md @@ -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 (name === 'test') { + if (hasName === 'test') { return false; } - return name; - } - - // bad - unnecessary function call - function (hasName) { - const name = getName(); - - if (!hasName) { + if (name === 'test') { + this.setName(''); return false; } - this.setFirstName(name); - - return true; + return name; } // 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; } ```