Created
May 29, 2017 17:03
-
-
Save nikolaswise/1173b7e9bfaffc61d313a51064a48fe1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // Get Nodes | |
| var buttonA = document.getElementById('a'); | |
| var buttonB = document.getElementById('b'); | |
| // Define functions | |
| var resultOne = function () { | |
| alert('Thing One') | |
| } | |
| var resultTwo = function () { | |
| alert('Thing Two') | |
| } | |
| var rollDice = function () { | |
| // return a random number between 0 and 100 | |
| return Math.floor(Math.random() * 100) | |
| } | |
| var thingOne = function () { | |
| var rando = rollDice(); | |
| if (rando < 75) { | |
| resultOne() | |
| } else { | |
| resultTwo() | |
| } | |
| } | |
| // Bind Events | |
| buttonA.addEventListener('click', thingOne); | |
| buttonB.addEventListener('click', thingTwo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment