Skip to content

Instantly share code, notes, and snippets.

@tomhodgins
Last active August 21, 2019 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomhodgins/bd40653cb6bc2188f51e5e235b454853 to your computer and use it in GitHub Desktop.
Save tomhodgins/bd40653cb6bc2188f51e5e235b454853 to your computer and use it in GitHub Desktop.
// If statements
var headline
if (variation === 1) {
headline = 'Variation B'
}
if (variation === 2) {
headline = 'Variation C'
}
// Switch statement
var headline
switch (variation) {
case 1:
headline = 'Variation B'
break
case 2:
headline = 'Variation C'
break
}
// Object lookup
var headline = ({
1: 'Variation B',
2: 'Variation C
})[variation]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment