Sololearn JavaScript course Functions answers

Here are all the questions and answers that I hope will help you learn JavaScript course.
Sololearn JavaScript course Overview answers
Sololearn JavaScript course Basic Concepts answers
Sololearn JavaScript course Conditionals and Loops answers
Sololearn JavaScript course Objects answers
Sololearn JavaScript course Core Objects answers
Sololearn JavaScript course DOM & Events answers
Sololearn JavaScript course ECMAScript 6 answers

24.1 Lesson

User-Defined Functions

Question:

JavaScript Functions
What is a function?

Answer:

Arithmetical term

Question:

Defining a Function
Add the corresponding keyword and symbols to create a function named "test".

Answer:

function test() 
{
  /* some code */
}

Question:

Calling a Function
Fill in the blanks to define and call the "hello" function.

Answer:

function hello() {
  alert("Hi there");
}
hello();

Question:

Calling Functions
How many times can the function be executed inside a web page?

Answer:

As many as needed

25.1 Lesson

Function Parameters

Question:

Function Parameters
What do you need to do to create a parameter?

Answer:

Write a variable name in the parentheses

Question:

Using Parameters
When and how is the parameter used?

Answer:

By calling the function and placing the value in the parentheses

Question:

Function Parameters
Drag and drop from the options below to declare a function and call it, by passing "Test" as the argument:x

Answer:

function  myAlert(txt) {
  alert("Hello " + txt);
}
myAlert("Test");

26.1 Lesson

Using Multiple Parameters with...

Question:

Multiple Parameters
What character is used to separate parameters from each other?

Answer:

,

Question:

Multiple Parameters
What is the output of this code?

function test(x, y) {
  if(x > y) {
    document.write(x);
  }
  else {
    document.write(y);
  }
}
test(5, 8);

Answer:

8

Question:

Multiple Parameters
Fill in the blanks to create a function alerting the sum of the two parameters.

Answer:

function myFunction(x, y){
  alert(x + y);
}

Question:

Multiple Parameters
How many times can the declared function be used?

Answer:

Any

27.1 Lesson

The return Statement

Question:

Function Return
When is the "return" statement most frequently needed?

Answer:

When you need to make a calculation and receive the result

Question:

Function Return
Where is the "return" statement placed?

Answer:

At the end of the function description

Question:

Function Return
Please enter the corresponding keyword to have the result of the function below displayed on the screen:

Answer:

function substrNumbrs(first, second) {
  var result = first - second;
  return result;
}
document.write(substrNumbrs(10, 5));

28.1 Lesson

Alert, Prompt, Confirm

Question:

The Alert Box
How many parameters can be accepted by the "alert" function?

Answer:

1

Question:

Prompt Box
Fill in the blanks to obtain the name of the user and alert it to the screen:

Answer:

var name =  prompt("Enter your name:");
alert(name);

Question:

Confirm Box
In the "confirm" dialog box, "OK" returns true, and "Cancel" returns ...

Answer:

false

29.1 Lesson

Module 4 Quiz

Question:

The following code will result in what value?

function test (number) {
  while(number < 5) {
    number++;
  }
  return number;
}
alert(test(2));

Answer:

5

Question:

What is the output of the following expression?

function multNmbrs (a, b) {
  var c = a*b;
}
multNmbrs(2, 6);

Answer:

Nothing

Question:

Please fill in the corresponding names for the built-in dialog boxes:

Answer:

prompt is for getting input from the user;
alert is for displaying a message in a box;

Question:

Fill in the blanks to calculate the maximum of the parameters:

Answer:

function max(a, b) {
  if (a >= b)
    return a;
  else
    return b;
}

Question:

What is the correct syntax for referring to an external script called "script.js"?

Answer:

<script src="script.js">

Question:

What alert will display on the screen?

function test (a, b) {
  if(a > b) {
    return a*b; 
  } else {
    return b / a; 
  }
}
alert(test(5, 15));

Answer:

3