title: How to get the array index in Lodash _.each
body: <p>I'm newbie in JavaScript. I have a question</p>
  
  <p>My code in Java:</p>
  
  <pre><code>public void checkArray(int a, int b) {
      int[]days = new int[]{5, 15, 25};
      int[]hours = new int[]{6, 8, 7};
      ArrayList&lt;Interger&gt; result = new ArrayList&lt;&gt;();
      for (int i = 0; i &lt; days.length-1;  i++) {
          if (days[i] &lt; a &amp;&amp; b &lt; days[i+1]) {
              result.add(hours[i]);
          } else if (days[i] &gt; a &amp;&amp; days[i] &lt; b) {
              result.add(hours[i]);
              if (i &gt; 0) {
                  result.add(hours[i-1]);
              }
          }
  </code></pre>
  
  <p>How can I write this code in JavaScript with Lodash <code>_.each</code>? I can't find a variable like [i] in JavaScript code, so I can't check the condition [if (days[i] &lt; a &amp;&amp; b &lt; days[i+1])]</p>
  
  <p>My code in JavaScript:</p>
  
  <pre><code>_.each(days, day =&gt; {
      //TODO something
  })
  </code></pre>