Skip to content

Commit 3ad1ad1

Browse files
cn0047ljharb
authored andcommitted
[guide] Updated example in ternaries.
1 parent e16b03b commit 3ad1ad1

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,16 +1914,15 @@ Other Style Guides
19141914
? "bar"
19151915
: value1 > value2 ? "baz" : null;
19161916
1917-
// better
1917+
// split into 2 separated ternary expressions
19181918
const maybeNull = value1 > value2 ? 'baz' : null;
19191919
1920+
// better
19201921
const foo = maybe1 > maybe2
19211922
? 'bar'
19221923
: maybeNull;
19231924
19241925
// best
1925-
const maybeNull = value1 > value2 ? 'baz' : null;
1926-
19271926
const foo = maybe1 > maybe2 ? 'bar' : maybeNull;
19281927
```
19291928

0 commit comments

Comments
 (0)