title: Understanding how to implement lodash's _.flowRight in vanilla JavaScript
body: <p>In school we have tasked to build an implementation of the <a href="https://lodash.com/docs#flowRight" rel="noreferrer">lodash method flowRight!</a></p>
  
  <p>In the spec it mentions:</p>
  
  <blockquote>
    <p>Takes an arbitrary amount of functions and returns a new function that
    uses its arguments and calls the provided functions from right to left
    (last to first). The argument for each function (except the first) is
    determined by the return value of the function to its right. The call
    to the function returned by flowRight evaluates to the return value of
    the left most function.</p>
  </blockquote>
  
  <p>And this is an example they give:</p>
  
  <pre><code>e.g.
  
  var sayHello = function (name) {
      return 'Hello, ' + name;
  },
  
  addExclamation = function (s) {
      return s + '!';
  },
  
  smallTalk = function (s) {
      return s + ' Nice weather we are having, eh?';
  };
  
  var greetEnthusiastically = flowRight(addExclamation, sayHello);
  
  greetEnthusiastically('Antonio');
  // --&gt; returns 'Hello, Antonio!'
  //(sayHello is called with 'Antonio', 
  //  addExclamation is called with 'Hello, Antonio')
  </code></pre>
  
  <p>I feel like I understand what is going on in a static example like this example demostrates. </p>
  
  <pre><code>function (func1, func2) {
      return function(value) {
          return func1(func2(value));
      }
  }
  </code></pre>
  
  <p>Guess I am having a hard time wrapping my brain around doing it in a loop, which I think you'll need. This is my implementation so far.</p>
  
  <pre><code>var flowRight = function (...args) {
      var Func;
      for(var i = args.length - 2; 0 &gt; i; i--) {
          function Func(value) {
              return args[i](args[i + 1](value));
          }
      }
      return Func;
  };
  </code></pre>
  
  <p>Any help will be appreciated!</p>