First off: This is not a react specific question.
Second: Your current code won't produce your expected output. some
only checks if any of the elments in an array pass a test and return true if any of them does, false otherwise. Your code also does not return any values, it just logs them to the console. There is also no logic in your code that performs any checks for duplicates or anything else.
Here is a your snippet modified to solve your problem.
function letter(get) {
let checkedLetters = "";
for (let i = 0; i < get.length; i++) {
const letter = get[i];
if (checkedLetters.includes(letter)) {
console.log(letter);
return letter;
}
checkedLetters += letter;
}
return undefined;
}
It will return the first duplicate letter in the provided string (and log it to the console), it will return undefined if there are no duplicates.