title: Refractor if statement
body: <p>I want to refractor a piece of code</p>
  <pre><code>if (res1 &amp;&amp; res1.e &gt; maxEnergy) {
      maxRes = res1;
      maxEnergy = res1.e;
  }
  if (res2 &amp;&amp; res2.e &gt; maxEnergy) {
      maxRes = res2;
      maxEnergy = res2.e;
  }
  if (res3 &amp;&amp; res3.e &gt; maxEnergy) {
      maxRes = res3;
      maxEnergy = res3.e;
  }
  </code></pre>
  <p>Is there any best way to do this piece of code in a shorter segment?
  With the use of Object literal or switch statement?</p>