From af096c8a940886b7ce5e802f01f81636fe977a41 Mon Sep 17 00:00:00 2001 From: Jake Teton-Landis Date: Tue, 10 Mar 2015 16:50:20 -0700 Subject: [PATCH] add `else` to docs --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 6e7c6f1b..906245e1 100644 --- a/README.md +++ b/README.md @@ -637,6 +637,29 @@ } ``` + - If you're using multi-line blocks with `if` and `else`, put `else` on the same line as your + `if` block's closing brace. + + ```javascript + // bad + if (test) { + thing1(); + thing2(); + } + else { + thing3(); + } + + // good + if (test) { + thing1(); + thing2(); + } else { + thing3(); + } + ``` + + **[⬆ back to top](#table-of-contents)**