I learn from wise guy: fun-fun-function reduce is a swish knife of functional programming, in this case:
[..."3123dasds JJKH e o a eee iJ"].reduce( (coll, chr) => coll[chr] ? {...coll, [chr]: coll[chr] + 1} : {...coll, [chr]:1 } , {});
this function is counting all alphabets in string.
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, {});
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I learn from wise guy: fun-fun-function reduce is a swish knife of functional programming, in this case:
this function is counting all alphabets in string.
you right!
to work with vowels need filter before this process: