-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
spellcheck/assets/scripts/practice.js
Line 130 in 340c2c4
| if ((lastActiveWord != null) & (activeWord==null)) { |
This is one of multiple instances of the 'bitwise and' operator being used where the 'logical and' operator should have been used.
bitwise AND: &
logical AND: &&
Logical AND (&&) takes the expression before it and the expression after it (both expressions should be booleans), combining to a larger expression that evaluates to a boolean. This boolean is true if both expressions fed to it are true. Since the two expressions fed to it use comparative operators (==, !=) they evaluate to booleans.
Bitwise AND is not evaluating the total expression to a boolean, but a number that happens to be truthy, so the code is working for the wrong reason.
Metadata
Metadata
Assignees
Labels
No labels