title: Filtering array by index and matching values
body: <p>I'm tying to filter out a pattern for a slot machine, in this case I want the following indexes to be selected if they have the same value.</p>
  
  <p>If indexes 0, 2 and 6 has the same value if should be outputted.
  I was thinking something like a function call maybe like this</p>
  
  <pre><code>if (win_filter([0, 2, 6] == "slot-2") {
      console.log("You won");
  }
  </code></pre>
  
  <p>My code is the following below.</p>
  
  <pre><code>var final_score = new Array();
  
  $(".shoot").click(function() {
  
    //var numbers_array = ["slot-1", "slot-1", "slot-1", "slot-1", "slot-1", "slot-2", "slot-2", "slot-2", "slot-2", "slot-3", "slot-3", "slot-3", "slot-4", "slot-4", "slot-5"];
    var numbers_array = ["slot-1", "slot-2", "slot-3", "slot-4", "slot-5"];
    var target = $("div.window table");
  
    target.find("tr td &gt; div").each(function() {
      $(this).fadeOut(function() {
        $(this).removeAttr('class');
        $(this).addClass(numbers_array[Math.floor(Math.random() * numbers_array.length)]);
        $(this).fadeIn();
        final_score.push($(this).attr("class"));
      });
    });
  
    function filterResults(arr) {
      return final_score.filter(function(el) {
        return arr.some(function(e) {
          return el.timeframe == e;
        });
      });
    }
  
    var result = filterResults(['0','2','6']);
    console.log(result);
  
    $.each(numbers_array, function(index, value) {
      if (result == value) {
        $(".notice").html("You have won.").addClass("success").show();
        console.log("You won!");
      }
    });
    console.log(final_score);
  });
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>If it wasn't clear I meant the indexes in the array, in case if I picked the indexes 0, 2 and 6 from this generated array the value of those would be (even if they aren't the same).</p>
  
  <pre><code>0 =&gt; "slot-2", 2 =&gt; "slot-5", 6 =&gt; "slot-1"
  </code></pre>
  
  <p>The goal is to check if the selected indexes has the same value output.
  And the amount of indexes shouldn't be hardcoded, it can be anything from 3 index searches to 5 index searches.</p>
  
  <p><a href="https://jsfiddle.net/qjp7g0qL/" rel="noreferrer">jsFiddle.net</a></p>
  
  <pre><code>Array[0]
  0 : "slot-2"
  1 : "slot-3"
  2 : "slot-5"
  3 : "slot-5"
  4 : "slot-4"
  5 : "slot-3"
  6 : "slot-1"
  7 : "slot-4"
  8 : "slot-1"
  9 : "slot-2"
  10 : "slot-2"
  11 : "slot-4"
  12 : "slot-5"
  13 : "slot-1"
  14 : "slot-4"
  </code></pre>