Skip to content

Instantly share code, notes, and snippets.

@alkrauss48
Created August 1, 2022 03:33
Show Gist options
  • Save alkrauss48/ee05b71c446cb72a2b1a8a3d19d5eec1 to your computer and use it in GitHub Desktop.
Save alkrauss48/ee05b71c446cb72a2b1a8a3d19d5eec1 to your computer and use it in GitHub Desktop.
How to handle rockin power
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