Skip to content

Instantly share code, notes, and snippets.

@louisbuchbinder
Created January 28, 2017 15:51
Show Gist options
  • Save louisbuchbinder/7a71e87d3081227a8514ba5b05b42fd9 to your computer and use it in GitHub Desktop.
Save louisbuchbinder/7a71e87d3081227a8514ba5b05b42fd9 to your computer and use it in GitHub Desktop.
Code Golf
// &&
if (true && true && true) // TRUTHY
if (true * true * true) // using multiplication converts true to 1 and multiplies each 1 together, (1 * 1 * 1) which evaluates to a truthy value
if (true && true && false) // FALSY
if (true * true * false) // (1 * 1 * 0) FALSY
// ||
if (true || false || false) // TRUTHY
if (true + false + false) // (1 + 0 + 0) TRUTHY
if (true || true || false) // TRUTHY
if (true + true + false) // (1 + 1 + 0) TRUTHY
if (false || false || false) // FALSY
if (false + false + false) // (0 + 0 + 0) FALASY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment