var a = [0,1,2,3];
how do I pass the value of getVal to prod and tst.
    function startFunc(){
     var deferred = Q.resolve();
     var a = [0,1,2,3];
     a.forEach(function (num, i) {
       var getVal = num;
       deferred = deferred
          .then(function(num){
            var def = Q.defer();
            console.log("\n\niteration:"+i + " a: "+getVal);
            return def.resolve(getVal);
          }).then(prod)
          .then(tst)
          .then(compare)
          .catch(function(error){
            console.log(error);
          });
      });
      return deferred.promise;
    }
here is a nodejs fiddle link. Goto the link and execute press shift+enter to exec. https://tonicdev.com/pratikgala/5637ca07a6dfbf0c0043d7f9
When this is executed I want to pass the value of getVal to prod as a promise.
how do I do that. when I run the following function the getVal is not returend to prod.
 
    