Created
August 1, 2022 03:33
-
-
Save alkrauss48/ee05b71c446cb72a2b1a8a3d19d5eec1 to your computer and use it in GitHub Desktop.
How to handle rockin power
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 MAX_ROCKIN_POWER = 12; | |
const MIN_ROCKIN_POWER = 7; | |
const MAX_PAYOUT = 350; | |
const MIN_PAYOUT = 20; | |
const FAILURE_PAYOUT = -50; | |
useEffect(() => { | |
let newAmount = wallet; | |
let message = ''; | |
if (rockinpower > MAX_ROCKIN_POWER) { | |
newWallet += MAX_PAYOUT; | |
message = 'Great job!'; | |
} else if (rockinpower > MIN_ROCKIN_POWEWR) { | |
newWallet += MIN_PAYOUT; | |
message = 'You made it this round!'; | |
} else { | |
newWallet += FAILURE_PAYOUT | |
message = 'oh no! This one didn\'t pan out. Try again. '; | |
} | |
setWallet(newAmount); | |
setMessage(message); | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment