Bummer! This is just a preview. You need to be signed in with a Treehouse account to view the entire video.
What each function does and how they all work together.
I figured I'd give you an overview of how it all works together, and
then run you through each function one at a time.
Let's start by looking at the game in the browser.
This program is going to take all the answers we put in for
each question and randomly pick one from each column.
It's also going to pick one choice from our mash array.
Then, it's going to fill in the sentence with the selected answer when we
press this button.
Now, that seems easy enough, but let's look inside the code.
This function at the top is going to pick a random number.
And, that's really all it's gonna do.
This second function,
mash_choice, is going to pick one of the items from our mash array.
Get_answer is going to
get a random answer from the available answers given in each category.
Fill-in-answer is going to
find the span tag that we need to fill in for each answer.
And, the handle submission function is going to wait for us to press the button,
build our answer object, and then call the function to fill in the answers.
It's then gonna show the div that reveals our future, or this div here.
You need to sign up for Treehouse in order to download course files.Sign up