I am creating an app where users earn trophies based on input. I want to alert the user when they earn a trophy. I'm uncertain how to write:
var trophy = false
if (userInput) {
trophy = true
}
// alert user when boolean changes from false to true after userInput
All the solutions I come up with alert the user when the boolean is true (which is every instance after the change), but I just want to alert once on change. The boolean will only ever flip once; once it's true, it never goes back to false.
Thanks!