Skip to content

Instantly share code, notes, and snippets.

@danhollick
Created February 4, 2020 09:15
Show Gist options
  • Save danhollick/dec1034d80def763c7d94ba9bc4e0e30 to your computer and use it in GitHub Desktop.
Save danhollick/dec1034d80def763c7d94ba9bc4e0e30 to your computer and use it in GitHub Desktop.
Calculation with side effects
function calculateAndSendContrast(foreground, alpha, backgound) {
// ...
let contrast = foregroundLuminance / backgroundLuminance
if (backgroundLuminance > foregroundLuminance) {
contrast = 1 / contrast
}
contrast = Math.floor(contrast * 100) / 100
return sendContrastInfo(contrast, foreground, backgound)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment