A function in Javascript follows a set of statements to calculate certain values and give us the output we are looking for. Most of the work in a program is done through functions. These functions allow the creators to easily create and reuse their code. There are a couple of qualifications a function must have to work, A function must have a name, be given zero or more pieces of information, and as a result, returns a value. To begin a function you start with the function keyword and place your function name right after it. Functions are run solely based on what they are being told to do through the code. Arguments in a function contain the values that are being passed through that function. These arguments are used to output the final result. Essentially these arguments contain the data attached to the function call. The images below are a great example of arguments in a function:
The parameters are the names of the variables that are included in the function definition. In this example, “a” and “b” are the variables that are included in the function. The argument here is assigning values to the variables stated in the parameter. “a” is being assigned the value of two, while “b” is being assigned the value of two as well. So the output of the function would be four, as it is adding both of the assigned values together. The function call in the example is the “add(2, 2)” placed at the bottom of the image. This is giving those values to the variables in the function definition.
I am responding after exam 3 and reading your post help me know I got some questions correct. Specifically, the explanation of function arguments because they pass a function. I could not remember in the middle of the exam.