How to check if a permutation is a palindrome in JavaScript

Here is one way to determine if a permutation is a palindrome in JavaScript.
Time complexity: O(n)
Space complexity: O(1)

permutationPalindromeTry in REPL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function palindromePermutation(string) {
const unpaired = string
.toLowerCase()
.split('')
.reduce((set, char) => {
if (char !== ' ') {
(set.has(char) && set.delete(char)) || set.add(char)
}
return set;
}, new Set());
return unpaired.size <= 1;
}

Test cases can be found at REPL.it