title: How can I use Promise.all with multiple arguments?
body: <p>I just started with Node.js. I have this code where i take the salary and the number of days and then calculate the average money you can spend per day until you get your next salary(5th of the month). The first promise is used to validate the user input and the second one actually calculates the result after the first promise is fulfilled. The code below works fine but i want to use Promise.all to get a deeper understanding of the topic.</p>
  
  <pre><code>var prompt = require('prompt');
  
  prompt.start();
  
  var promise1 = function(){
      return new Promise(function(resolve,reject){
          prompt.get(['salary','day'],function(err,result){
              var x = result.salary;
              var y = result.day;
              var z =  /^[0-9]*$/;
  
              if(x.match(z) &amp;&amp; y.match(z))
              {
                  resolve(result);
              }
              else{
                  reject('invalid day or salary');
              }
  
          })
      })
  }
  
  var promise2 = function(x,y){
      //console.log('x is ' + x);
      return new Promise(function(resolve,reject){
          if(y&gt;=1 &amp;&amp; y&lt;5){
              var z = x/(5-y);
              resolve(z);
          }
          else if(y&lt;=30 &amp;&amp; y&gt;5){
              var z = x/(35-y);
              resolve(z);
          }
          else{
              reject('day not within range...');
          }
      })
  }
  
  
  
  promise1().then(function(resolve){
      return promise2(resolve.salary,resolve.day);
  
  }).then(function(resolve){
      console.log(resolve);
  }).catch(function(fromReject){
      console.log(fromReject);
  })
  </code></pre>