Skip to content

Instantly share code, notes, and snippets.

@SlimTim10
Created May 27, 2018 13:24
Show Gist options
  • Save SlimTim10/1504ff638da31177404713bc6e581b1d to your computer and use it in GitHub Desktop.
Save SlimTim10/1504ff638da31177404713bc6e581b1d to your computer and use it in GitHub Desktop.
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