Skip to content

Instantly share code, notes, and snippets.

@ChrisDobby
Created February 5, 2020 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisDobby/020612f10caf65f96559efa95ea031c2 to your computer and use it in GitHub Desktop.
Save ChrisDobby/020612f10caf65f96559efa95ea031c2 to your computer and use it in GitHub Desktop.
function evenWord(word) {
let charCounts = [...word].reduce(
(charCount, char) => ({
...charCount,
[char]: charCount[char] ? charCount[char] + 1 : 1,
}),
{},
);
return Object.entries(charCounts).filter(([_, count]) => count % 2 !== 0).length;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment