median()
Table of Contents
Overview
The median() function takes numberList as an argument, sorts it in ascending order, and returns the median (lying in the middle) value in the list. If the number of elements is even, the average of the middle two elements will be returned.
Return Type
- Decimal
Syntax
<variable> = <numberList>.median();
(OR)
<variable> = median(<numberList> );
Parameter | Description | Data type |
---|---|---|
<variable> | Variable which will contain the returned value. | DECIMAL |
<numbeList> | The list from which the median value will be returned. Numerical values can be specified in double quotes. | NUMBER LIST or DECIMAL LIST |
Examples
numberList = {1, 5, 2, 3};
medianValue= numberList.median(); // returns 2.5
medianValue= numberList.median(); // returns 2.5