Skip to content

Instantly share code, notes, and snippets.

@angelorubin
Created October 8, 2018 01:14
Show Gist options
  • Save angelorubin/30e0ed8653e6ea81cd7985319d3d7a83 to your computer and use it in GitHub Desktop.
Save angelorubin/30e0ed8653e6ea81cd7985319d3d7a83 to your computer and use it in GitHub Desktop.
'use strict'
const filter = (arr, func) => {
return (function filterInternal (arrayInternal, counter) {
const [head, ...tail] = arrayInternal
return arrayInternal.length === 0
? []
: (func(head, counter, arr) ? [head] : []).concat(filterInternal(tail, counter + 1))
})(arr, 0)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment