title: How to replace an if statement with an alternative?
body: <p>In an article titled <a href="https://dev.to/joelnet/rethinking-javascript-the-if-statement-9cg" rel="nofollow noreferrer">Rethinking JavaScript: The if statement</a>, it says:</p>
  <blockquote>
  <p>I have recently been questioning the if statement itself.</p>
  <p>Having written an entire application completely void of a single if statement, I have found if to be optional.</p>
  </blockquote>
  <p>I would like to understand how to replace this code:</p>
  <pre class="lang-js prettyprint-override"><code>  if (value &lt;= 0) {
      return 0;
    }
  </code></pre>
  <p>with a non-if alternative, as the article suggests.</p>
  <p>The first suggestion in the article is a ternary operator:</p>
  <pre class="lang-js prettyprint-override"><code>condition ? expr1 : expr2
  </code></pre>
  <p>The article suggests that &quot;<em>almost every instance of an if statement could be replaced with an equivalent ternary operation</em>&quot;, but this could not replace my code - it would replace an <code>if else</code> statement, not an <code>if</code>.</p>
  <p>Another article by the same author, <a href="https://dev.to/joelnet/functional-programming-how-would-you-if-no-else-javascript-59ai" rel="nofollow noreferrer">Functional Programming: Alternatives to the IF</a>, says:</p>
  <blockquote>
  <p>This function has an if statement without an else. So while a ternary operator could work, it is not ideal.<br />
  ...<br />
  One option is to use a short circuit operator:</p>
  <pre class="lang-js prettyprint-override"><code>item &amp;&amp; dispatch({ type: 'ACTION', item })
  </code></pre>
  </blockquote>
  <p>This however does not replace my code because I get a linting error: <code>Expression expected.</code> - This is correct - it is enforcing correct use of logical operators.</p>
  <p>I tried a logical operator like this:</p>
  <pre class="lang-js prettyprint-override"><code>const maxValue = (value &lt;= 0) &amp;&amp; 0;
  return maxValue;
  </code></pre>
  <p>But this does not replace the <code>if</code> statement because the function that the <code>if</code> statement is in must return a number, and this returns <code>'false | 0'</code>.</p>
  <p>So my question is, how do I follow the article's advice and replace the if statement with an alternative?</p>