title: Know the last number equal to another within an array in Javascript
body: <pre><code>const numbersArray = [5, 3, 1, 3, 4, 5, 3, 1];
  
  var pastNumbers = [];
  
  for (let i = 0; i &lt; numbersArray.length; i++) {
    const number = numbersArray[i];
    pastNumbers.push(number);
    var count = 0;
    pastNumbers.forEach((v) =&gt; (v === number &amp;&amp; count++));
    console.log(`There are ${count} numbers before equal to ${number}. The last equal number is in the ${???} position.`);
  }
  </code></pre>
  <p>I have an array called <code>pastNumbers</code> that stores the numbers that were previously traversed by the <code>for</code> loop of another array called <code>numbersArray</code>. Then with <code>forEach</code> I get the amount of previous numbers equal to <code>number</code>.</p>
  <p>I want to know the position of the last number equal to <code>number</code> within the <code>pastNumbers</code> array.
  How can I do it?</p>