Javascript Developer JSE 40 01 · Free Practice Question Medium

Question 27

Q543 - Functions


You have defined the following arrow function:



Select the correct regular declarations

of the corresponding function or function expression.


(Select two correct answers)


  • A
  • B
  • C
  • D
Reveal correct answers

Correct answers: C, D

Explanation

Topics: function declaration function expression


Try it yourself:


Explanation:

Only two of the functions return the value.


The function declaration (function statement) defines a function.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function


Function expression

The function keyword can be used to define a function inside an expression.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function


(There is a similar question Q329.)


Q543 (Please refer to this number, if you want to write me about this question.)

A. This choice is incorrect because it assigns the product of m and n to m within the function, which is not the same behavior as the arrow function that calculates and returns the product.

B. This choice is incorrect because it lacks a return statement, so the function does not return the product of m and n as intended.

C. This choice correctly represents the arrow function as a regular function declaration with the function keyword, parameter list, and return statement that calculates the product of m and n.

D. This choice correctly represents the arrow function as a regular function expression using the let keyword to declare the function and the function keyword with a parameter list and a return statement that calculates the product of m and n.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need