I\'ve been trying to calculate median but still I\'ve got some mathematical issues I guess as I couldn\'t get the correct median value and couldn\'t figure out
Short and sweet.
Array.prototype.median = function () { return this.slice().sort((a, b) => a - b)[Math.floor(this.length / 2)]; };
Usage
[4, 5, 7, 1, 33].median()
Works with strings as well
["a","a","b","b","c","d","e"].median()