title: How to compare specific items in array inside of basic lodash loop
body: <p>This is the basic JavaScript for loop I'm trying to replace:</p>
  
  <pre><code>for (var i=0; i&lt;tickers.length; i++) {
      if (tickers[i].ticker === selectedTicker) {
          selectTicker('portfolio', tickers[i]);
          break;
      }
  }
  </code></pre>
  
  <p>Here is the <a href="https://lodash.com/docs" rel="nofollow noreferrer"><strong>lodash</strong></a> version</p>
  
  <pre><code>_.times((tickers.length), function() {
      if (tickers[i].ticker === selectedTicker) {
          selectTicker('portfolio', tickers[i]);
          return;
      }
  });
  </code></pre>
  
  <p>Obviously this errors out currently, because there is no <code>[i]</code> variable set in the lodash version.</p>
  
  <p>The lodash version is much more readable imho, just do this many times the length of my tickers array.</p>
  
  <p>However I need to compare the ticker of each object to the <code>selectedTicker</code>.</p>
  
  <hr>
  
  <p><strong>UPDATE: Adding screenshot and link to prove to some asking that _lodash is faster than native Javascript.</strong></p>
  
  <p><a href="http://jsperf.com/forloop-vs-each-from-lodash" rel="nofollow noreferrer">http://jsperf.com/forloop-vs-each-from-lodash</a></p>
  
  <p><a href="https://i.stack.imgur.com/3DKXT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3DKXT.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/Iztvb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Iztvb.png" alt="enter image description here"></a></p>