function total(numbers) {
  var sum = 0;
  // shorthand for (var i = 0; i < numbers.length; i++)
  for (var i in numbers) {
    sum += numbers[i];
  }
  return sum;
}

function mean(numbers) {
  return total(numbers)/numbers.length;
}

function median(numbers) {
  // note that sort is destructive and by itself treats numbers as strings, necessitating extra compare function, asc
  // shorthand compare for function(a, b){return a-b}
  numbers.sort((a, b) => a - b);

  var midPoint = (numbers.length -1) / 2;

  return (numbers[Math.floor(midPoint)] + numbers[Math.ceil(midPoint)]) / 2;
}

// alternative, which is faster?
function median(numbers) {
  numbers.sort(function(a, b){return a-b});

  var midIndex = Math.floor(numbers.length / 2);

  if ((numbers.length % 2) == 0) {
    return (numbers[midIndex] + numbers[midIndex - 1]) / 2;
  } else {
    return numbers[midIndex];
  }

}

function mode(numbers) {
  // Your code here!
  // Ex. Mode array:
  // var mode = { 5:3, 6:3 }
}

@@ -664,34 +664,23 @@
 ort(
-function(a, b)%7Breturn a-b%7D
+(a, b) =%3E a - b
 );%0A%0A
@@ -869,17 +869,16 @@
 x%5D;%0A  %7D%0A
-%0A
 %7D%0A%0Afunct
@@ -901,77 +901,333 @@
 ) %7B%0A
-  // Your code here!%0A  // Ex. Mode array:%0A  // var mode = %7B 5:3, 6:3 %7D
+%0A// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort%0A%0A  // sort array and compare =%3E function(a, b) %7B if (a===b) %7B... %7D%0A    // - if numbers are equal%0A      // - set counter and keep track of maxCount%0A      // - assign to currentMode if maxCount is more than current maxCount%0A  //  -%0A
 %0A%7D%0A

add pseudocode for Mode