DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Discussion on: JavaScript Programming Problem 2

Collapse
 
hijazi313 profile image
Muhammad Hamza Hijazi Author

this function is counting all alphabets in string.

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