JavaScript How to combine functions in another FP?

I am learning function programming in JavaScript, currently I have the following code.

I would like to combine this two functions in another function which alllow an user to pass a value in and having the result equal to the value passed plus 10 multiply 3 using the following functions.

Pseudo code example:

 const myFormulat= add(10).multiply(3);

How can I write this function using only vanilla JS ES6?

function add(x){
  return function(y){
    return y + x;
  };
}

function multiply(x){
  return function(y){
    return y * x;
  };
}

// my calculation
// get x add 10 and after multiply by 3
Answer:1

See: http://scott.sauyet.com/Javascript/Talk/Compose/2013-05-22/

function add(x){
  return function(y){
    return y + x;
  };
}

function multiply(x){
  return function(y){
    return y * x;
  };
}

Function.prototype.compose = function(g) {
     var fn = this;
     return function() {
         return fn.call(this, g.apply(this, arguments));
     };
};

var f = multiply(3).compose(add(10));

console.log(f(5));
Answer:2

I am attempting to do jasmine-node unit testing on my node.js project. I need to get an array of file paths and then pass that array to the unit test. However, since this is asynchronous, I have to ...

I am attempting to do jasmine-node unit testing on my node.js project. I need to get an array of file paths and then pass that array to the unit test. However, since this is asynchronous, I have to ...

  1. return value asynchronous method javascript
  2. return value asynchronous function
  3. return value asynchronous swift
  4. return asynchronous value
  5. return value from asynchronous function javascript
  6. javascript return value asynchronous
  7. return value from asynchronous java
  8. return value ajax asynchronous
  9. return value from asynchronous callback
  10. promise return value asynchronous
  11. asynchronous return value c#
  12. node return value from asynchronous function

I need to add multiple attribute to input type file but I don't know how to do it. Below My code: var input = document.createElement("input"); input.type = "file"; input.id = "files" + af; input....

I need to add multiple attribute to input type file but I don't know how to do it. Below My code: var input = document.createElement("input"); input.type = "file"; input.id = "files" + af; input....

After long time searching here around I can't find a solution to this problem, loading Datatables via Ajax GET is well documented but how can I use directly a JSON response after an Ajax POST? This ...

After long time searching here around I can't find a solution to this problem, loading Datatables via Ajax GET is well documented but how can I use directly a JSON response after an Ajax POST? This ...

  1. load datatables from json
  2. load datatables from ajax
  3. datatables load from csv
  4. datatables load from array
  5. datatables load from json string
  6. datatables load from json file
  7. datatables load from api
  8. datatables load from server
  9. datatables load from object
  10. datatables js onload
  11. datatables load from table
  12. load datatables with filter
  13. datatables load from json
  14. datatables load data from ajax
  15. datatables load data from json
  16. datatables load data from array
  17. datatables load data from object
  18. datatables load data from variable
  19. datatables load data from server
  20. datatables load data from json file

I have a video the being played. How can I call a function 5 seconds before the end of the video? I thought to put a timer when I start the video, the problem is that the user can control the video, ...

I have a video the being played. How can I call a function 5 seconds before the end of the video? I thought to put a timer when I start the video, the problem is that the user can control the video, ...