1 Answers
📚 Topic Summary
JavaScript functions are reusable blocks of code that perform a specific task. Think of them like mini-programs within your main program. They help you organize your code, make it easier to read, and prevent you from having to write the same code multiple times. A function is defined using the function keyword, a name, parentheses () (which may contain parameters), and curly braces {}, which enclose the function's code.
When you want to use a function, you "call" it by its name followed by parentheses. If the function expects any parameters, you provide those values inside the parentheses when you call it. Functions can also return values using the return keyword.
🗂️ Part A: Vocabulary
Match the following terms with their definitions:
- Term: Parameter
- Term: Function Call
- Term: Return Value
- Term: Function Definition
- Term: Scope
- Definition: The part of the program where a variable can be accessed.
- Definition: The actual value passed to a function when it is called.
- Definition: The code that creates and names a function.
- Definition: The act of executing a function.
- Definition: The value a function sends back after it is executed.
✍️ Part B: Fill in the Blanks
Complete the following sentences using the words provided (function, parameters, return, call, JavaScript):
A _______ is a reusable block of code. You define a function with the keyword _______. When defining a function, you can include ________ inside the parentheses, which are like placeholders for values you pass in. To use a function, you _______ it by writing its name followed by parentheses. A function can _______ a value, which is the result of the function's operation.
🤔 Part C: Critical Thinking
Explain in your own words why functions are useful in programming. Give an example of a task that could be performed by a function, and explain how using a function would make the code easier to manage.
Join the discussion
Please log in to post your answer.
Log InEarn 2 Points for answering. If your answer is selected as the best, you'll get +20 Points! 🚀