use map to count length of each element in an array

Solutions on MaxInterview for use map to count length of each element in an array by the best coders in the world

showing results for - "use map to count length of each element in an array"
Amelia
07 Aug 2020
1var lengths = chars.map(function(word){
2 return word.length
3}) 
Ariadna
25 Jun 2017
1var words = ['Hello', 'world'];
2
3var lengths = words.map(function(word) {
4  return word + ' = ' + word.length;
5});
6
7console.log(lengths);
similar questions