GitHub 6219★

Find the length of the longest string in an array

JavaScript version

const findLongest = (words) => Math.max(...words.map((el) => el.length));

TypeScript version

const findLongest = (words: string[]): number => Math.max(...words.map((el) => el.length));

Example

findLongest(['always', 'look', 'on', 'the', 'bright', 'side', 'of', 'life']); // 6
Follow me on and to get more useful contents.