Skip to content

Instantly share code, notes, and snippets.

@nathan-lapinski
Created June 4, 2018 11:42
Show Gist options
  • Save nathan-lapinski/b8a6f73c781f36ba35b36c15c1720c6e to your computer and use it in GitHub Desktop.
Save nathan-lapinski/b8a6f73c781f36ba35b36c15c1720c6e to your computer and use it in GitHub Desktop.
Implementing Filter
Array.prototype.filter = function(predicateFn) {
let retVal = [];
for (let i = 0; i < this.length; i++) {
if (predicateFn(this[i]) {
retVal.push(this[i]);
}
}
return retVal;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment