Рекорды по прыжкам в длину 30/30 (пример выполнения))

var qualificationDistance = 200;
var attempts = [120, 150, 160, 201, 203, 180, 202];
var qualified = false;
var averageBest = 0;
var maxValue = 0;
var avg = 0;

//sort
for (var i = 0; i <= attempts.length - 2; i++) {
var minValue = attempts[i];

for (var j = i + 1; j <= attempts.length - 1; j++) {
if (attempts[j] < minValue) {
minValue = attempts[j];
var swap = attempts[i];
attempts[i] = minValue;
attempts[j] = swap;
}
}
}

// massiv
console.log(attempts);
// summ 3 records
for ( i = attempts.length-1; i>=attempts.length-3;i–){
averageBest +=attempts[i];
console.log(attempts[i]);
}
// find AVG
averageBest = averageBest/3;

//test
if (averageBest>qualificationDistance){
qualified = true;}
else{
qualified = false;}

Мой вариант

for (var i = 0; i < attempts.length - 1 ; i++) {
  var max = attempts[i];  
  for (var j = i + 1; j <= attempts.length - 1; j++) {
    if (attempts[j] > max) {
      max = attempts[j];
      var swap = attempts[i];
      attempts[i] = max;
      attempts[j] = swap;
      }
    }
  }

averageBest = (attempts[0] + attempts[1] + attempts[2])/3;
if (averageBest > qualificationDistance) {
  qualified = true;
  } else {
    qualified = false;
    }