Skip to content

Instantly share code, notes, and snippets.

@tomhodgins tomhodgins/conditions.js
Last active Aug 21, 2019

Embed
What would you like to do?
// 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
You can’t perform that action at this time.