title: Javascript function that takes a function OR any parameter to be evaluated by that function
body: <p>I was asked today to create a function <code>validate</code> so that I can use it was such:</p>
  
  <pre><code>validate(input =&gt; input &gt; 2);
  validate(5) // return true
  validate(input =&gt; input ** 2);
  validate(5) // return 25
  </code></pre>
  
  <p>I have thought about this and I can only think of a common pattern instantiating the function with another validator function like so:</p>
  
  <pre><code>const validate = (input =&gt; input)(input =&gt; input &gt; 2);
  validate(5) // returns true
  </code></pre>
  
  <p>However, this did not accomplish the requirement since I cannot pass another validator function after I have already defined it in the constructor. </p>
  
  <p>How do I accomplish this? </p>