Nice! Here's my implementation:
const solve = word => word.split(/[uoiea]/) .map(s => s.split('') .reduce((acc, c) => acc + (c.charCodeAt(0) - 96), 0)) .sort((a, b) => b-a)[0];
Very nice, I wasn't aware of the c.charCodeAt(0) - 96 rule, didn't work with chars very much in all these years to be honest.
c.charCodeAt(0) - 96
It only works with lowercase a to z, because UTF-16 represents them as contiguous code points, starting at 97.
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.
Nice! Here's my implementation:
Very nice, I wasn't aware of the
c.charCodeAt(0) - 96
rule, didn't work with chars very much in all these years to be honest.It only works with lowercase a to z, because UTF-16 represents them as contiguous code points, starting at 97.