Skip to content

Instantly share code, notes, and snippets.

@MarchCorbin
Created March 30, 2020 17:34
Show Gist options
  • Save MarchCorbin/10f6e6706049c5042731d67d2ddc5a16 to your computer and use it in GitHub Desktop.
Save MarchCorbin/10f6e6706049c5042731d67d2ddc5a16 to your computer and use it in GitHub Desktop.
How to Make an 8 ball magic
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