Skip to content

Instantly share code, notes, and snippets.

@rjcorwin
Last active June 24, 2020 15:02
Show Gist options
  • Save rjcorwin/e4c0714c28efb7960d8532e959959c16 to your computer and use it in GitHub Desktop.
Save rjcorwin/e4c0714c28efb7960d8532e959959c16 to your computer and use it in GitHub Desktop.
shouldGridAutoStop() {
const firstXButtons = tangyToggleButtons.slice(0, this.autoStop)
const hasAtLeastOneUnpressedButton = firstXButtons
.reduce((hasAtLeastOne, button) => hasAtLeastOne || button.pressed === false ? true : false, false)
return hasAtLeastOneUnpressedButton ? false : true
}
@rjcorwin
Copy link
Author

rjcorwin commented Jun 24, 2020

Reduce "trip wire" is written as such where yourCondition() is your custom condition of something you are looking to find at least once....

arrayOfItems.reduce((hasAtLeastOne, item) => hasAtLeastOne || yourCondition(item) ? true : false, false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment