title: Node.js : Assign value in an array element then calculate score
body: <p>I have an array of ids that are the intersection of two arrays. I want to assign a value per element in the intersection array. Below is my incomplete code of how to proceed:</p>
  
  <pre><code>//intersection array
  var interArray= ["5ghIJDpPoe3CfHMGu71E6T","69Saih0L7exhpURTx2TN3r","7biThmNOfzA4nZR9h2B6DL",
      "51m0PrZokFZNk5b5xptyzC","1XPta4VLT78HQnVFd1hlsK"];
  
  //Edited getting score
  function calculateScore (interArray, callback) {
     var tmp = 0;
     for(i = 0; i &lt; interArray.length; i++) {
       tmp++;
     }
     var score = (tmp/22) * 0.5; //22 for example is the total length of the two arrays that were combined
     callback(null, score);
  }
  </code></pre>
  
  <p>Is this procedure correct/efficient if I want to predict the similarity of two arrays?</p>
  
  <p>P.S. I used underscore.js to get the intersection and this is running on a Node.js API service</p>
  
  <p>Thank you!</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>So basically I have two arrays. The first array is a collection of IDs from the user. The second array is a collection of IDs from users. These IDs refer to items that are referenced to to each </p>
  
  <pre><code>async.parallel([
     function(callback) {
       async.waterfall([getUser,getItems], 
         function(err, results) {
           callback(null, results);
       });
     },
     function(callback) {
       async.waterfall([getUsers,getItems], 
         function(err, results) {
           callback(null, results);
         });
     }
  ], function(err, results) {
       var currentUserArray = results[0]; //item ids from user
       var matchedUsersArray = results[1]; //item ids per user
  
       function mapUsersArray () {
           //Get the item ids per matchedUser
       }
       function getIntersection() {
          //Get intersection of currentUserArray and matchedUsersArray[i]
       }
  
       //Compute similarity/match score of ids of currentUser per matchedUser
  });
  </code></pre>
  
  <p>Restating the questions: <em>Is this procedure correct or efficient? How can I calculate their similarity/match score? And since I mapped the matchedUsersArray, how can I get the matchedUser details again so I can send it as a response along with the matchScore</em>?</p>