Find the Median

  • + 2 comments

    Can anyone explain why this doesn't work?

    function findMedian(arr: number[]): number {
    	let sorted = arr.sort();
    	const mid = Math.floor(arr.length / 2);
    	return sorted[mid];
    	}