Is there a way to get the index of the new array while filtering

I have a variable, idx, that controls the current index of an array of elements called items. While running a filter on this array, I want to change idx to current index of the filtered array if it matches a condition.

let idx = 5; //6 in the array
let items = [1, 2, 3, 4, 5, 6, 7, 8, 9];

// Filter evens only
let evens = items.filter(function(num) {
    if (!isEven(num))
        return false;
    if (num == 6)
        idx = INDEX_IN_EVENS_ARRAY(would be 2 in this case);
    return true;
});

129 thoughts on “Is there a way to get the index of the new array while filtering”

  1. Pingback: generic for viagra
  2. Pingback: sildenafil 20 mg
  3. Pingback: eli lilly cialis
  4. Pingback: viagra generic
  5. Pingback: viagra canada
  6. Pingback: viagra pill
  7. Pingback: viagrasao.com
  8. Pingback: viagra 100mg uk
  9. Pingback: costco viagra cost
  10. Pingback: cialis discount
  11. Pingback: sildenafil 100mg
  12. Pingback: viagra tablet
  13. Pingback: viagra men
  14. Pingback: womens viagra
  15. Pingback: viagra use
  16. Pingback: viagra tablets
  17. Pingback: viagra online
  18. Pingback: walgreens viagra
  19. Pingback: goodrx sildenafil
  20. Pingback: viagra or cialis
  21. Pingback: walmart viagra
  22. Pingback: female viagra
  23. Pingback: cvs viagra