lib/algorithms.js
function(otherUserId, callback){
          // if there is only one other user or the other user is the same user
          if (otherUserIdsWhoRated.length === 1 || userId === otherUserId){
            // then call the callback and exciting the similarity check
            callback();
          }
          // if the userid is not the same as the user
          if (userId !== otherUserId){
            // calculate the jaccard coefficient for similarity. it will return a value between -1 and 1 showing the two users
            // similarity
            jaccardCoefficient(userId, otherUserId, function(result) {
              // with the returned similarity score, add it to a sorted set named above
              client.zadd(similarityZSet, result, otherUserId, function(err){
                // call the async callback function once finished to indicate that the process is finished
                callback();
              });
            });
          }
        }
function(otherUserId, callback){
          // if there is only one other user or the other user is the same user
          if (otherUserIdsWhoRated.length === 1 || userId === otherUserId){
            // then call the callback and exciting the similarity check
            callback();
          }
          // if the userid is not the same as the user
          if (userId !== otherUserId){
            // calculate the jaccard coefficient for similarity. it will return a value between -1 and 1 showing the two users
            // similarity
            jaccardCoefficient(userId, otherUserId, function(result) {
              // with the returned similarity score, add it to a sorted set named above
              client.zadd(similarityZSet, result, otherUserId, function(err){
                // call the async callback function once finished to indicate that the process is finished
                callback();
              });
            });
          }
        }
function ( otherUserId , callback ) { // if there is only one other user or the other user is the same user if ( otherUserIdsWhoRated . length === 1 || userId === otherUserId ) { // then call the callback and exciting the similarity check callback ( ) ; } // if the userid is not the same as the user if ( userId !== otherUserId ) { // calculate the jaccard coefficient for similarity. it will return a value between -1 and 1 showing the two users // similarity jaccardCoefficient ( userId , otherUserId , function ( result ) { // with the returned similarity score, add it to a sorted set named above client . zadd ( similarityZSet , result , otherUserId , function ( err ) { // call the async callback function once finished to indicate that the process is finished callback ( ) ; } ) ; } ) ; } }
running a function on each item in the list
running a function on each item in the list