Created
September 7, 2019 09:53
-
-
Save Lodo4ka/12f71a57f2c3106fc828454a3b0b5221 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const fn = (f, list) => { | |
if(list.length === 0) { | |
return []; | |
} | |
const [x, ...xs] = list | |
return f(x) ? [x, ...fn(f, xs)]: fn(f,xs) | |
} | |
const arrEx = [4, 2, 5, 1, 3]; | |
const param = (a) => a === 4 | |
console.log(fn(param, arrEx)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment