Skip to content
Advertisement

Calculate Median and Average of a Text FIle with Multiple Columns of Data

I have a file with multiple columns of data.

I need to calculate the median and average of the two columns.

Input:

JavaScript

Desired Output:

JavaScript

I have tried

JavaScript

Which is good for only one column of data.

Advertisement

Answer

Here I’m assuming you meant to work with columns and calculate two sets of values. Your output format is not reflecting this assumption though.

It’s better to write functions for this task. However, your implementation is not correct to begin with. For median you have to sort the values first. Also the mid point calculation is not correct.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement