Fix Typo in logical operators
true || alert("printed") false || alert("not printed") This is confusing to a student as the first won't be printed, but the second will print "not printed". I've reversed it to this so it makes much more sense to a learner: true || alert("not printed") false || alert("printed")
This commit is contained in:
parent
24224dc2ec
commit
f9ad7195e0
1 changed files with 2 additions and 2 deletions
|
@ -128,8 +128,8 @@ This leads to some interesting usage compared to a "pure, classical, boolean-onl
|
|||
In the example below, the first message is printed, while the second is not:
|
||||
|
||||
```js run no-beautify
|
||||
*!*true*/!* || alert("printed");
|
||||
*!*false*/!* || alert("not printed");
|
||||
*!*true*/!* || alert("not printed");
|
||||
*!*false*/!* || alert("printed");
|
||||
```
|
||||
|
||||
In the first line, the OR `||` operator stops the evaluation immediately upon seeing `true`, so the `alert` isn't run.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue