Skip to content

Instantly share code, notes, and snippets.

@asodemann18
Created March 30, 2020 17:22
Show Gist options
  • Save asodemann18/3da6dbfb169df15d34bdcaf13e7dd282 to your computer and use it in GitHub Desktop.
Save asodemann18/3da6dbfb169df15d34bdcaf13e7dd282 to your computer and use it in GitHub Desktop.
  1. Declare a variable for an array that holds the possible magic 8 ball responses
  2. Create a function called getRandomIndex that takes in one parameter (the array) and returns a random number relative to the length of the array
  3. Create a second function called getFortune that applies the random index from the funtion getRandomIndex but outputs the corresponding value instead of just a number
  4. Create an input box that allows users to ask their question
  5. Create a submit button for the user to click after they've typed their question
  6. Once the submit button is clicked, the getFortune function should run a random magic 8 ball response should show up
  7. The user should be able to ask the same question multiple times
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment