Title:
JavaScript Functions
Updated:
October 23, 2023
Task/Activity:
  1. Questions
  2. Coding Problems
A. Questions
What is a function, and why would you ever want to use one in your code?
A function is a pre-programmed set of instructions that can be applied throughout your code should you not want to repeat that same code.
What do you call the 'inputs' that get passed into a function?
Parameters
Do all functions have return values?
No
What is the 'body' of a function, and what are the characters that enclose the body of a function?
The body of a function is what determines what the function is supposed to do, and it is encased in 'curly brackets', or these {}.
What does it mean to 'call', or 'invoke' a function (note that 'calling' and 'invoking' a function mean the same thing)?
Simply to use it within the code.
If a function has more than one parameter, what character do you use to separate those parameters?
A comma.
What is the problem with this code (explain the syntax error)?

function convertKilometersToMiles(km)
    return km * 0.6217;
}
                
It's missing the starting curly bracket.
B. Coding Problems
Coding Problems - See the 'script' tag below this section. You will have to write some JavaScript code in it.

Always test your work! Check the console log to make sure there are no errors.