So some will tell you a function really isn't a function unless you're returning a value, so it functions
really have the three parts, they have the input.
So this is the data that's sent into the function, the code that gets a run and then also the output.
And this is commonly a value that's returned by the function example.
We've got two numbers that are being passed in and we're returning back the two values, but we're adding
them together.
So we're doing something with the content that's being passed in and returning back, something that's
been computed out of the function, something different.
So we've got a quick math option.
And math is one of the great examples that we can use because it's really simple and we can show you
how you can multiply so you can create a function to do multiplication of any two numbers.
And also notice as well that there is no semicolon at the end.
The semicolon is within the block of code and it's straight after within the return.
So we're all we're doing is we're taking in the two values and then we're taking X times Y and we're
returning back that computed value.
So there is a challenge in this lesson and that's to create a function that multiplies two values and
returns the result.
And ideally, what we want to do is put it into the console.
So something like this where we're calling a function called multiplier and we're passing in the two
numbers and then we're seeing the result being returned back.
So this could be 10 and five or any combination that return back 50.
So go ahead and pause the video, try it out.
And this is a quick peek at what the solution is and I'll walk you through it coming up.
I hope you had an opportunity to try this out for yourself.
And this was a really quick, short example of how to use a function.
And this can be number one.
So we can equal that to one hundred and number two can be two hundred, create our function, taking
in value eight and value B and then returning back.
The result, you can also set up a temporary holder for that as well.
So you could take A and B and then return back temp or you could do it all within one statement.
The result is going to be the same.
And then next we need to consider log out the value of multiplier and we have them as variables so we
can take value of number one and number two and we can see what gets output in the console.
So it gets the solution output in the console.
And we also saw within the example as well that we can create the function in a different format as
well.
And there's going to be more on this coming up.
And we'll just call this multiplier two and then we're going to equal that to an anonymous function,
taking in the two values, the two parameters to return back A times B or if we wanted to, we could
write it within the same way as well.
So all the block of the code that's inside is the same thing.
It doesn't matter how you rate it a function expression, you do have to define it before you try to
use it.
Otherwise you're going to get an error in your code.
So if I do try to do it like this, you're going to see it throws an error.
So that means that we do need to have the function and we have to define it before we try to use it.
So that's the real difference between the two, is that this one we can use at any point so we could
even use it before we're defining the function and we're not going to throw any errors.
And of course, we are going to be covering this in a little bit more detail coming up.
So go ahead and try that out.
And if you did the second option as well.
So this is valid and an invalid format as well for a solution.