You might not need if statements: a better approach to branching logic
David Gilbertson

I like json, but sometime I would prefer something like

const decision = {
decide: decision[`logged_in_${user.loggedIn()}`],
logged_in_true: decision[`is_premium_${user.isPremium()}`],
logged_in_false: decision[`has_searched_${user.hasSearched()}`],
is_premium_true: showSupportWidget(),
is_premium_false: showTipOfTheDay()

And separate object for labels if needed.

No IFs used :-D

Show your support

Clapping shows how much you appreciated Robert ShockiTV Simon’s story.