So this is what I'm doing:I have hundreds of arrays, each of them filled with a date in milliseconds in the first position, and the rest of the array is filled with user game scores.Let's just call this array above var scoresDatesThe ultimate goal is to have each of those arrays contain only the date in milliseconds, the smallest score and then the largest score, in that order. To do this, I set up for loop within a for loop, that will loop the larger array and the systematically make several operations until the end result is achieved. I would like to see if there are better ways to do it or optimize this process.This is what I have...// Logic that stacks all the scores per unique day from all the user's game scores. All unique dates with subsequent scores are stored in the uniqueDaysScores array.uniqueDaysScores = [];uniqueDaysScores.push(scoresDates[0]);for(var i = 0, ii = scoresDates.length; i < ii; i++){  var tempArray = [];  if(scoresDates[i][0] == uniqueDaysScores[0][0]){    uniqueDaysScores[0].push(scoresDates[i][1]);  } else{    tempArray.push(scoresDates[i][0]);    tempArray.push(scoresDates[i][1]);    uniqueDaysScores.unshift(tempArray);  }}// Storted scores from smallest to largest for each unique date for user games played. scoreSorted = [];// Logic to take all the scores, sort them from decreasing to increasing order, then package the date, lowest and shortest score into the finished array, scoreSorted.for(var i = 0, ii=uniqueDaysScores.length; i < ii; i++){  var scoreSorted1 = [];  var scoreSortedPrimer = [];// First level for loop that goes through the unique scores array and ignores the date, while pushing all the scores into the scoreSorted1 array.  for(var z = 0, zz = uniqueDaysScores[i].length; z < zz; z++){    if(uniqueDaysScores[i][z] < 1000){      scoreSorted1.push(uniqueDaysScores[i][z]);    }  }  // Next step is sorting the scoreSorted1 array from lowest score to highest score.  scoreSorted1.sort(function(a,b){    return a-b;  });  // Find maximum and minimum scores in the array and finally push them into the scoreSortedPrimer array.  var primerMin = Math.min.apply(Math, scoreSorted1);  scoreSortedPrimer.push(primerMin);  var primerMax = Math.max.apply(Math,scoreSorted1);  scoreSortedPrimer.push(primerMax);  // Finally, find the date and push it into the scoreSortedPrimer array, so it can be pushed into the main scoreSorted array.  for(var x = 0, xx = uniqueDaysScores[i].length; x < xx; x++){    if(uniqueDaysScores[i][x] > 1000){      scoreSortedPrimer.unshift(uniqueDaysScores[i][x]);    }  }  uniqueDaysScores.push(scoreVarianceSortedPrimer);}The uniqueDaysScores array will contain all the arrays with the date first and the lowest and highest score thereafter. I have added comments to make it easier to follow. It kind of seems like a long process and I'm just curious if there is a more experienced programmer that can see where this script can be optimized or improved.
Extracting the timestamp, minimum score, and maximum score from hundreds of arrays
javascript;array