Which of the following is the correct way to call the function below?

var multiplier = function(number) {

console.log(3 * number);

};

Answer: multiplier(5);

What does the return keyword do?

Answer: It allows for the output of a function to be used elsewhere

Which of the following is a local variable in the block of code below?

var input = prompt("Enter input value");

var controlVal = input / 2 + 3;

var multiplier = function(number, phase) {

var val = number * controlVal + phase;

console.log(val);

};

Answer: val

Which of the following demonstrates correct syntax for a function?

\/\/1;

var myFunction = function[] {};

\/\/2;

var myFunction = function() {};

\/\/3;

var myFunction = function{} ();

\/\/4;

var myFunction = function(); {};

Answer: 2;

How many global variables are there in the following block of code?

var input = prompt("Enter input value");

var controlVal = input / 2 + 3;

var multiplier = function(number, phase) {

var val = number * controlVal + phase;

console.log(val);

};

Answer: 3;

Which of the following is a parameter in the block of code below?

var input = prompt("Enter input value");

var controlVal = input / 2 + 3;

var multiplier = function(number, phase) {

var val = number * controlVal + phase;

console.log(val);

};

Answer: number

Which of the following correctly calls this function?

var input = prompt("Enter input value");

var controlVal = input / 2 + 3;

var multiplier = function(number, phase) {

var val = number * controlVal + phase;

console.log(val);

};

Answer: multiplier(2, 1);

Which of the following is a global variable in the block of code below?

var input = prompt("Enter input value");

var controlVal = input / 2 + 3;

var multiplier = function(number, phase) {

var val = number * controlVal + phase;

console.log(val);

};

Answer: input

The input into a function is called:

Answer: parameter

Which of the following best describes what a function in JavaScript is used for?

Answer: A reusable piece of code that can be called on throughout an application

results matching ""

    No results matching ""