Created
May 27, 2018 13:24
-
-
Save SlimTim10/1504ff638da31177404713bc6e581b1d 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
const action1 = () => { | |
console.log('Trying thing that fails.') | |
return false; | |
}; | |
const action2 = () => { | |
console.log('Trying thing that succeeds.'); | |
return true; | |
}; | |
const action3 = () => { | |
console.log('Trying another thing that succeeds.'); | |
return true; | |
} | |
const action4 = () => { | |
console.log('Trying yet another thing that succeeds.'); | |
return true; | |
} | |
// const degrade = actions => { | |
// for (let action of actions) { | |
// const r = action(); | |
// if (r) return r; | |
// } | |
// }; | |
const degrade = actions => actions.every(action => action() ? false : true); | |
console.log(degrade([action1, action2, action3, action4])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment