addNumbers with two parameters: num1 and num2num1 and num2console.logaddNumbers with two parameters: num1 and num2num1 and num2console.logaddNumbers that takes two parameters called num1 and num2. For now, leave the function body empty.Use the function keyword followed by the function name and parentheses with parameters.
addNumbers function, write a return statement that returns the sum of num1 and num2.Use return num1 + num2; to send back the sum.
result and assign it the value returned by calling addNumbers with the numbers 5 and 7.Use const result = addNumbers(5, 7); to call the function and save the answer.
console.log to print the value of the variable result.Use console.log(result); to show the sum in the console.
What is the purpose of function parameters in JavaScript?
Choose the best explanation.
Which of the following is the correct way to define a function with two parameters a and b in JavaScript?
function add(???) { return a + b; }What will be the output of this code?
function greet(name) {
return `Hello, ${name}!`;
}
console.log(greet('Alice'));Find the error in this function definition:
function multiply(x, y) {
return x * y;
}
multiply(5);What will happen when multiply(5) is called?
Consider this function that uses default parameters:
function calculateTotal(price, tax = 0.1, discount = 0) {
return price + price * tax - discount;
}
console.log(calculateTotal(100, undefined, 5));What is the output of the console.log statement?
Pass the test and this pattern moves unknown