Advertisement
collinsanele

count

May 25th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. let list = ["a", "bb", "a", "bb", "ccc"];
  3.  
  4. function wordCount(arr){
  5.   let obj = {};
  6.   arr.forEach((item)=>{
  7.     obj[item] = item.length;
  8.   });
  9.   return obj;
  10. }
  11.  
  12.  
  13.  
  14. console.log(wordCount(list));
  15. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement