This function finds the length of the longest string in an array.
JavaScript:
let longestStringLength = arr => Math.max(...arr.map(str => str.length));
// Example
console.log(longestStringLength(['short', 'medium', 'longest'])); // 7
console.log(longestStringLength(['a', 'ab', 'abc', 'abcd'])); // 4
TypeScript:
let longestStringLength = (arr: string[]): number => Math.max(...arr.map(str => str.length));
// Example
console.log(longestStringLength(['short', 'medium', 'longest'])); // 7
console.log(longestStringLength(['a', 'ab', 'abc', 'abcd'])); // 4