I'm currently learning JavaScript and got stuck by adding a parameter to my function that should add two numbers. I'm not new to programming. Did a lot in Java and C#, but Javascript drives me crazy with scope and compose and currying.... So here is my problem:
const compose = (f, g) => (a) => f(g(a));
const add1 = (num) => num + 1;
const add5 = (num) => num + 5;
compose(add1, add5)(10) // 16
The code above works! But i want that the +1 and +5 number to be variable so that i can have like this:
// Something linke this
const compose = (f, g) => (a,b) => f(g(a,b));
const add1 = (num, num2) => num + num2;
const add5 = (num, num2) => num + num2;
compose(add1, add5)(10, 4) // Those numbers should be the Parameter input for add1 and add5 (num, num2)
function compose(){...}? No one gives extra marks for making things complicatedf(g(a, b)),g(a, b)is 1st parameter and 2nd parameter is missing