// Return highest element from array
const getMax = (arr: number[]): number =>
arr.reduce((max, current) => {
return current > max ? current : max;
}, arr[0]);
Last active
March 6, 2025 08:10
-
-
Save fieldse/fb88c814c9251062f50012b677117501 to your computer and use it in GitHub Desktop.
Get the largest element from an integer array in Typescript using `reduce()`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment