How to calculate the average length of the strings in string array with Node.js

1 Answer

0 votes
const arr = ["c#", "c", "c++", "node.js", "python"]   
 
const avg = arr.join('').length / arr.length     
 
console.log(avg)
 
 
    
/*
run:
    
3.8
    
*/

 



answered Aug 20, 2024 by avibootz
edited Aug 20, 2024 by avibootz
...