<commit_before>//Refactor

function sum(integer_array) {
  var total = 0;
  for (var i = 0; i < integer_array.length; total += integer_array[i++]);
  console.log(total);
}

var array = [4,5,6,7,8,9];
console.log(sum(array));

/*
SUM

As a user, I want to input a list of numbers and have the program output their sum by
printing the result to the console.

*/


//Refactor
function mean(integer_array) {
  var length = integer_array.length
  var total = sum(integer_array);
  return total/length;
 }

var array = [4,5,6,7,8,9];
console.log(mean(array));

/*
MEAN

As a user, I want to input a list of numbers, and have them added together and divided
by the number of items in the list, giving me the average, and printing the result to the console.

*/


function median(integer_array) {
  var arr_length = integer_array.length
  if (integer_array % 2 === 0){
    var middle_two = [];
    middle_two.push(arr_length / 2 - 1);
    return mean(middle_two);
    }
 else {
  var middle_index = (arr_length - 1) / 2;
    return integer_array[middle_index];
  }
}

var array = [4,5,6,7,8];
console.log(median(array));

//Refactor

/*
MEDIAN

As a user, I want to input a list of numbers. If that list of numbers contains an odd amount of numbers,
I want the program to output the number in the middle of the list. If the list contains an even
amount of numbers, I want the program to output the sum of the two numbers in the middle of the list,
divided by two.

*/<commit_msg>Fix bugs<commit_after>//Refactor

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

/*
SUM

As a user, I want to input a list of numbers and have the program output their sum by
printing the result to the console.

*/


//Refactor
function mean(integer_array) {
  var length = integer_array.length
  var total = sum(integer_array);
  return total/length;
 }

/*
MEAN

As a user, I want to input a list of numbers, and have them added together and divided
by the number of items in the list, giving me the average, and printing the result to the console.

*/


function median(integer_array) {
  var arr_length = integer_array.length
  if (integer_array % 2 === 0){
    var middle_two = [];
    middle_two.push(arr_length / 2 - 1);
    return mean(middle_two);
    }
 else {
  var middle_index = (arr_length - 1) / 2;
    return integer_array[middle_index];
  }
}

//Refactor

/*
MEDIAN

As a user, I want to input a list of numbers. If that list of numbers contains an odd amount of numbers,
I want the program to output the number in the middle of the list. If the list contains an even
amount of numbers, I want the program to output the sum of the two numbers in the middle of the list,
divided by two.

*/
{'fraction_non_alphanumeric': 0.09343434343434344, 'fraction_numerical': 0.011904761904761904, 'mean_word_length': 3.494327390599676, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '647638', 'n_tokens_mistral': 901, 'n_tokens_neox': 877, 'n_words': 378}