Created
March 30, 2020 17:34
-
-
Save MarchCorbin/10f6e6706049c5042731d67d2ddc5a16 to your computer and use it in GitHub Desktop.
How to Make an 8 ball magic
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
Start by making an array of strings that can be potential returns from the magic 8 ball. | |
Turn this array into a variable that we can reference later lets call it 'answers' | |
create a function called magicBallOfMagicEight | |
Create a for loop that is going to go through the length of the array of potential answers. | |
create a function that will draw a random index number from our array using Math.random * answers.length and make it into a variable 'randomAnswer' | |
Now we will reference our randomAnswer and pull from the list using bracket notation so we dont just get back a number but the answer itself and lets make it a variable called 'myOwnAnswer' | |
make the function RETURN myOwnAnswer | |
Fire! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment