Skip to content

Instantly share code, notes, and snippets.

@Pierre-M
Created January 7, 2020 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pierre-M/546597a49ab46ee6964b03c3e438f93c to your computer and use it in GitHub Desktop.
Save Pierre-M/546597a49ab46ee6964b03c3e438f93c to your computer and use it in GitHub Desktop.
Interview question by Cassidy Williams (2020-01-06 newsletter)
Array.prototype.filter = function(predicate) {
const filteredArray = [];
this.forEach((el, idx) => {
if (predicate(el, idx, this)) {
filteredArray.push(el);
}
});
return filteredArray;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment