How to find the longest string size of an array of strings in TypeScript

1 Answer

0 votes
const strings: string[] = ["c++", "python", "c#", "javascript", "swift", "java"];
 
const longestStringSize: number = Math.max(...(strings.map(el => el.length)));
  
console.log(longestStringSize);
 
 
 
/*
run:
 
10
 
*/

 



answered Oct 2, 2024 by avibootz
...