DEV Community

Discussion on: JavaScript Programming Problem 2

Collapse
 
pengeszikra profile image
Peter Vivo

you right!

to work with vowels need filter before this process:


const countChars =  
 (coll, chr) => coll[chr] 
   ? {...coll, [chr]: coll[chr] + 1} 
   : {...coll, [chr]:1 };

const vowels = "aeiouóöőüúűáé"; // hungarian vowels included

const filterWovels = chr => vowels.indexOf(chr) > -1;

const vowelCount = s => [...s.toLowerCase].filter(filterWovels).reduce(countChars, {});
Enter fullscreen mode Exit fullscreen mode