Q:

Write a function that takes a binary function to a method

I found a coding problem with the solution but no explanation of why this solution works. I was hoping someone could help me understand how does the solution work.

A binary function is a function that takes two inputs and returns
  a value, like for example add(3,5) -> 8. Write a function named
  "methodification", that converts a binary function to a method. For
  example:

function add (a, b) {return a + b;}
Number.prototype.add = methodification(add);
(3).add(5) === 8; // true

and this is the solution: 
function methodification (func) {
  return function (b) {
    return func(this, b); 
  };
}

What is the logic behind this solution?

A:

First thing to say is that nobody would ever code like this in real life, but it's a very good example of how functional programming works in JS. Explanation:
Number.prototype.add = function(b) { return this + b; }

is what you want the final result to be. Since 3 has prototype Number you can syntactically treat it like you would an object and call methods on it, in those methods 3 === this is true. Knowing this you can deduce that methodification(add) must be the right hand side of the above line of code, so it must be a function, thus methodification must be a function that takes a function as parameter, in this case "add", and returns another function, so methodification is a so-called higher order function. So now you could "cheat" and do
function methodification(func) {
    return function(b) {
       return this + b;
    }
}

simply returning the right hand side and ignoring the parameter func, but since this + b === add(this, b) you can do what the solution says. And that's all, no magic required.

