function last<T>(arr: T[]): T | undefined { return arr[arr.length - 1] }
last([1, 2, 3]) // β 3
last([]) // β undefinedlast<T> returns the final element, or undefined for an empty array.
Challenge: Implement last<T>(arr: T[]): T | undefined returning the last element.
last([1, 2, 3]) // β 3
last([]) // β undefined