All files / src/elementAt Iterator.elementAt.js

100% Statements 4/4
100% Branches 2/2
100% Functions 1/1
100% Lines 4/4
1 2 3 4 5 6 7 8 9 10    18x 4x 11x 2x        
import Iterator from '../iterators/Iterator';
 
Iterator.prototype.elementAt = function elementAt(index) {
  for (let item of this) {
    if (index-- === 0) {
      return item;
    }
  }
};