Solución
solution.tsTypeScript
export function indexOfMax(nums: number[]): number {
const { index } = nums.reduce<{ max: number, index: number }>(
(state, current, index) =>
(current > state.max) ? ({ max: current, index }) : state,
{ max: -Infinity, index: -1 }
)
return index;
}0respuestas