enter image description hereHere is my current code:
-
Html
Dice - Roll above 50 to win
-
Javascript
var randomNum = Math.floor((Math.random() * 100) + 1); var pass = 50;
if ( randomNum > pass ) { msg = 'You won! '; } else { msg = ' You lost! ' }
var el = document.getElementById('info'); el.textContent = msg + 'You rolled: ' + randomNum;
Scenario:
- Person clicks button for free credits
- Button adds 5 Credits to his balance
- He clicks a button to run the dice
- If he wins +10 to his balance, if he loses -5 to his balance
How would someone code that? ( I am a beginner in js ) Thanks!
Aucun commentaire:
Enregistrer un commentaire