Last active
July 26, 2019 16:42
-
-
Save msarit/ce15fb6c8cb980bae6e190f4c48f56cf to your computer and use it in GitHub Desktop.
example-code.js
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
| function getRandomInt(max) { | |
| return Math.floor(Math.random() * Math.floor(max)); | |
| } | |
| function setAction(actions){ | |
| let action = actions[getRandomInt(6)]; | |
| if (action === 'gives away') { setAction(actions) } | |
| else { return action } | |
| } | |
| function setItem(items){ | |
| const item = items[Math.floor(Math.random() * items.length)]; | |
| return item; | |
| } | |
| function setLocation(locations){ | |
| const location = locations[Math.floor(Math.random() * locations.length)]; | |
| return location; | |
| } | |
| function tongueTwister(actions, items, locations){ | |
| const thisAction = setAction(actions); | |
| const thisItem = setItem(items); | |
| const thisLocation = setLocation(locations); | |
| return `She ${thisAction} ${thisItem} by the ${thisLocation}; the ${thisItem} she ${thisAction} are ${thisLocation} ${thisItem}`; | |
| } | |
| export default tongueTwister; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment