use .map to count length of each element in an array

62

var lengths = chars.map(function(word){
 return word.length
}) 
var words = ['Hello', 'world'];

var lengths = words.map(function(word) {
  return word + ' = ' + word.length;
});

console.log(lengths);

Comments

Submit
0 Comments