Thursday , September 19 2024

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?

Questions BankCategory: JavaScript Essentials 1Examine 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?
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