title: How can I avoid nested ternary expressions in my code?
body: <p>I have code like this. How can I write it in cleaner, more elegant way using functional programming in JavaScript? I want to get rid of nested ternary expressions. Any ideas?</p>
  
  <pre><code>props =&gt; ({
              iconColor: props.isPriority ? (props.isCompleted ? variables.color.lightpurple : variables.color.purple ) : variables.color.gray3,
              iconName: props.isPriority ? 'star-full' : 'star-empty',
            }))
  </code></pre>
  
  <p>This is rest of that code:</p>
  
  <p><strong><em>EDIT:</em></strong></p>
  
  <pre><code>const enhance: React$HOC&lt;*, InitialProps&gt; = compose(
        withProps(props =&gt; ({
          iconColor: props.isPriority ? (props.isCompleted ? variables.color.lightpurple : variables.color.purple) : variables.color.gray3,
          iconName: props.isPriority ? 'star-full' : 'star-empty',
        }))
      )
  </code></pre>