Last active
June 25, 2020 16:53
-
-
Save kijuky/2ac56c388124c8b8f1dcab040672881a 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 arr = [ ... ]; // なにか配列 | |
const pred = e => ...; // なにか述語 | |
const {result} = arr.reduce((acc, cur) => { | |
if (acc.finished) { return acc; } | |
acc.finished = !pred(cur); | |
if (acc.finished) { return acc; } | |
acc.result.push(cur); | |
return acc; | |
}, {result: [], finished: false}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment