I am trying to find a unique word in my input string with JS and have written a code. However, my code doesn’t work and I don’t know why. Could anyone help me please?
function findUniqueWord(index){
var show = []
var result = [...index]
for (let i = 0; i < result.length; i++) {
for (let j = i + 1; j < result.length; j++) {
if(result[i] === result[j]){
}
else{
return show.push(result[i])
}
}
}
return show
}
console.log(findUniqueWord('A2A'));