##### Related Content

Programmers and Teachers: Nikkolas K.
Tutor and degreed Aerospace Engineer

# Median Calculator ## Lesson on Medians

### What is the Median?

The median of a set of numbers is the number in the middle. When an odd set of numbers is sorted, the middle number itself is the median. When an even set of numbers is sorted, the median is halfway between the two middlemost numbers. For an in-depth look at the median, see our lesson How to Find the Median.

## How the Calculator Works

The calculator on this page is written in the programming language JavaScript. The code is run by your internet browser’s engine which is what allows the calculator to give instant results without the page reloading.

When the “calculate” button is clicked, the median function is triggered. First, the function filters and sorts the inputted numbers based on the comma separator. Then, it determines if the list of numbers is odd in length or even in length.

If the list of numbers is odd, it picks the middle number as the median. If the list of numbers is even, it finds the average of the two middlemost numbers.

Once the function finds the median, it displays the sorted number list and median below the “calculate” button. If any errors occur due to incorrect input syntax, it instead displays an error notice.

Scroll to Top