Skip to content

Instantly share code, notes, and snippets.

@joshuaaguilar20
Last active August 6, 2021 02:46
Show Gist options
  • Save joshuaaguilar20/e4ff6ce8c175252da63fcd6500f1d82a to your computer and use it in GitHub Desktop.
Save joshuaaguilar20/e4ff6ce8c175252da63fcd6500f1d82a to your computer and use it in GitHub Desktop.
Wait for it health

How to wait for function to become true or false.

const startGame = () => {
return new Promise((res,rej) => {
while(health >= 0){
  console.log("ATTACKED")
  console.log(health)
  if (health === 0) {
    res('GAME OVER')
    break;
  }
  health--
}
  })
}

const isOver = startGame()

if(isOver){ console.log(isOver) }}

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