-
-
Notifications
You must be signed in to change notification settings - Fork 25
Closed
exercism/website-copy
#2356Description
Instead of returning boolean literals after a condition, you can directly return the condition instead.
Example:
// instead of
if (knightIsAwake) {
return true;
} else {
return false;
}
// ... return the expression directly
return knightIsAwake;
THIS IS INCORRECT. If knightIsAwake = true, then we cannot do a fast attack (false)
If you were to return the direct condition, it will fail.
if knightIsAwake then we return true which is false
if !knightIsAwake then we return false which should be true that we CAN do a fast attack
Metadata
Metadata
Assignees
Labels
No labels