re: Much needed filterMap in JavaScript VIEW POST

FULL DISCUSSION
 
Array.prototype.filterMap = function(filter) {
   const r = [];
   for(let i=0; i<this.length; i++) {
      const item = filter(this[i], i, this);
      if (item !== undefined) {
         r.push(item);
      }
   }
   return item; // should be `return r`. right.?
};```

 
code of conduct - report abuse