Examine the following code:
let x = mult(2)(10); console.log(x); // -> 20
What should the mult
function declaration look like if the execution of this code results in a value of 20
in the console?
-
let mult = function (a, b) { return b ? mult(b) : mult(a); }
-
let mult = function (a, b) { return a * b; }
-
let mult = function (a) { return function (b) { return a * b; } }
- There is an error in the code and it is not possible to declare such a function correctly.
More Questions: JavaScript Essentials 1 – JSE1: Final Test
Please login or Register to submit your answer