How to calculate the average length of the strings in string array with TypeScript

1 Answer

0 votes
const arr: string[] = ["c#", "c", "c++", "typescript", "python"]   

const avg: number = arr.join('').length / arr.length     

console.log(avg)


   
/*
run:
   
4.4
   
*/

 



answered Aug 20, 2024 by avibootz
...