Skip to content

Commit 10becba

Browse files
committed
(Coding Convention) Use stacked else/catch clauses.
1 parent 6972e92 commit 10becba

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

CodingConvention.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,29 @@ if (true)
8787

8888
Also, notice the use of whitespace before and after the condition statement.
8989

90+
Follow the JavaScript convention of stacking `else/catch` clauses on the same line as the previous closing brace.
91+
92+
*Right:*
93+
94+
~~~ {.javascript}
95+
if (i % 2 === 0) {
96+
console.log('even');
97+
} else {
98+
console.log('odd');
99+
}
100+
~~~
101+
102+
*Wrong:*
103+
104+
~~~ {.javascript}
105+
if (i % 2 === 0) {
106+
console.log('even');
107+
}
108+
else {
109+
console.log('odd');
110+
}
111+
~~~
112+
90113
## Variable declarations
91114

92115
Declare one variable per var statement. Try to put those declarations at the beginning of each scope.

0 commit comments

Comments
 (0)