Created
October 8, 2018 01:14
-
-
Save angelorubin/30e0ed8653e6ea81cd7985319d3d7a83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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