Solución
solution.tsTypeScript
function findMedian(numbers: number[]): number {
// Tu solución aquí
const sortedArr = numbers.sort(( a, b ) => a - b)
if ( sortedArr.length % 2 !== 0 ) return sortedArr[(sortedArr.length-1)/2]
return (sortedArr[Math.floor((sortedArr.length-1)/2)] + sortedArr[Math.ceil((sortedArr.length-1)/2)]) / 2;
}
// No modificar: necesario para evaluar el resultado.
export { findMedian };0respuestas