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:
Moudi Kawi 2020-05-08 16:56:08 +01:00 committed by GitHub
parent 24224dc2ec
commit f9ad7195e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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.