title: How to filter out object in options in javascript
body: <p>I have  determine the cheapest, best and fastest rate in the object based on the factors below:</p>
  
  <ul>
  <li>cheapest is determined by <code>netfee</code> having the least value</li>
  <li>fastest is determined by <code>speed</code> having the least days</li>
  <li>best is determined by <code>amount</code> having the highest value</li>
  </ul>
  
  <p>But what if the fastest speeds are the same? Then on what factor should depend on without conflicting other two? If for example the 'fastest' is determined by using <code>speed</code> having less days &amp;&amp; <code>amount</code> having the highest value, it conflicts the <code>best</code> resulting best and fastest are same</p>
  
  <p>I need to know on what factor should depend on when speed is same for all</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var obj = [{
    id: "sample1",
    netfee: 10,
    speed: "1days",
    amount: "100",
    rate: "0.5",
    netamount: "50"
  }, {
    id: "sample2",
    netfee: 6,
    speed: "1days",
    amount: "200",
    rate: "0.1",
    netamount: "20"
  }, {
    id: "sample3",
    netfee: 4,
    speed: "3days",
    amount: "500",
    rate: "0.2",
    netamount: "100"
  }];
  
  var cheapest = obj.reduce((acc, cur) =&gt; (acc.netfee &lt; cur.netfee ? acc : cur)).id,
    fastest = obj.reduce((acc, cur) =&gt; (parseInt(acc.speed, 10) &lt; parseInt(cur.speed, 10) ? acc : cur)).id,
    best = obj.reduce((acc, cur) =&gt; (Number(acc.amount) &gt; Number(cur.amount) ? acc : cur)).id;
  
  console.log("cheapest =", cheapest)
  console.log("fastest  =", fastest)
  console.log("best     =", best)</code></pre>
  </div>
  </div>
  </p>