curriculum/challenges/english/blocks/review-javascript-functions/6723c5b8601a40a100bb59c9.md
function keyword followed by a name, a list of parameters, and a block of code that performs the task.:::interactive_editor
function addNumbers(x, y, z) {
return x + y + z;
}
console.log(addNumbers(5, 3, 8)); // Output: 16
:::
undefined.return keyword is used to specify the value to be returned from the function and ends the function execution.:::interactive_editor
const calculateTotal = (amount, taxRate = 0.05) => {
return amount + (amount * taxRate);
};
console.log(calculateTotal(100)); // Output: 105
:::
:::interactive_editor
const multiplyNumbers = function(firstNumber, secondNumber) {
return firstNumber * secondNumber;
};
console.log(multiplyNumbers(4, 5)); // Output: 20
:::
:::interactive_editor
const calculateArea = (length, width) => {
const area = length * width;
return `The area of the rectangle is ${area} square units.`;
};
console.log(calculateArea(5, 10)); // Output: "The area of the rectangle is 50 square units."
:::
function keyword.:::interactive_editor
const cube = x => {
return x * x * x;
};
console.log(cube(3)); // Output: 27
:::
return keyword.:::interactive_editor
const square = number => number * number;
console.log(square(5)); // Output: 25
:::
{} such as in if statements, or loops.let and const provides even finer control over variable accessibility, helping to prevent errors and make your code more predictable.Review the JavaScript Functions topics and concepts.