Do you remember Schoolhouse Rock? No, not Jack Black's timeless classic School of Rock, but the animated educational series? Please say yes, otherwise my picture above and the entirety of this blog won't make any sense.
Depending on the function, sometimes you can have two, three, five or even twenty parameters of information to add.
Conjunction Junction's Function
Conjunction Junction is a train junction is Schoolhouse Rock where train cars (which are different words) are combined with three "special" train cars (conjunction words) to form complete trains (sentences). It's fun concept and the stupid song has been ingrained into my head since 1994. Since I have to suffer because of it, so do you.
To begin, let's make and alert a sentence.
Simple enough. Now let's make a function and call it "conjunctionJunction" and put our sentence in there instead.
Functions are a little more complicated than some of the things you've seen before. They start with the word function and a response is returned at the end of it. Since we have the variable sentence calling that conjunctionJunction function, the sentence will be returned and alerted.
Now that the conjunctionJunction function has a function, we can hook up some words and phrases and clauses. (I am really sorry about this, but it's just going to get worse from here.) Let's take the word "and" out of the sentence and put it between the brackets of the conjunctionJunction function.
We're now passing the word "and" into the function as the variable word, and adding that into our sentence. Let's see what happens if we do this:
We can add variables into functions to change the outcome. It's fairly simple so far, so let's make it a little more complicated. We're going to add another conjunction word into our conjunctionJunction function.
But (see what I did there?) now it doesn't make sense. We need to do an if statement and change our sentence for this new conjunction word in our conjunctionJunction function.
Adding multiple parameters
Now that we are junctioning different types of conjunction words into our conjunctionJunction function, let's make it a little more complicated:
By adding multiple parameters, we could have a wider variety of responses come out of our function. While these examples are all based around text, we could do something with numbers as well.
If you made it this far with all my terrible jokes and you have no idea what I'm talking about, here's a video that explains it.