title: Calling a function with parameters inside another function
body: <p>I am trying to build a kind of scheduler function, able to call another function with parameters at random instants in time.
  Here is my attempt, using Javascript:</p>
  
  <pre><code>function scheduleFunction(t, deltaT, functionName) {
  
      var timeout;
      var timeoutID;
  
      function scheduler() {
        functionName()
  
        clearTimeout(timeoutID);
        timeout = Math.trunc(Math.random() * 2 * deltaT - deltaT) + t;
        timeoutID = setTimeout(scheduler, timeout);
      }
  
      scheduler();
  
    }
  </code></pre>
  
  <p>This function works properly if I let it call another function that doesn't require parameters. For instance:</p>
  
  <pre><code>function printSomething() {
          console.log("Printing something...");
        }
  
  scheduleFunction(1000, 500, printSomething);
  </code></pre>
  
  <p>Unfortunately, that function doesn't allow to call another function with parameter, that is - for example:</p>
  
  <pre><code>function print(string) {
          console.log(string);
  }
  
  scheduleFunction(1000, 500, print("Hello World!"));
  </code></pre>
  
  <p>How should I edit the scheduler function in order to obtain that kind of result, if possible?</p>