JavaScript Functions
Learning Objective
I can write a JavaScript function to perform a specific task.
Key Concepts
A JavaScript function is a sub program that performs a specific task, such as calculate, print, or process data.
To declare a function, you start with the function keyword, then the function name, parentheses, and curly brackets containing the code to be executed.
A function can only return one thing, but you can return an object containing multiple values if needed.
Practice Questions
This lesson includes 9 practice questions to reinforce learning.
View questions preview
1. What keyword is used to declare a function in JavaScript?
2. What is the primary purpose of parameters in a JavaScript function?
3. In JavaScript, what is the primary purpose of the function block (the code within the curly brackets {})?
...and 6 more questions
Educational Video
JavaScript for Beginners - Functions
saperis