JSFiddle - React, Tailwind, and code Playground
JavaScript
function testStr (str) {
let arr = str.split('')
let unique = [...new Set(arr)]
return unique.filter(char => {
let count = 0
let searchIndex = 0
while (true) {
index = str.indexOf(char, searchIndex)
if (index == -1) break;
count+=1
searchIndex = index + 1
}
return !!(count % 2)
})
}
console.log(testStr ('abbadddd'));
console.log(testStr ('abbbaccddd'));