I've been working on a task to identify the unique element within an array. I've made progress and managed to solve 95% of it, but I'm encountering an issue with one particular situation. The error message reads 'expected 0 and got 1'.
The result should be //10, which is correct when I test it locally. However, it fails when I run the online test. It has passed for all other input values except this specific scenario.
Does anyone have any suggestions on how to resolve this issue? What am I overlooking here?
function findOne(arr) {
let x = arr[0];
for (let i of arr) {
if (i === x) {
continue;
} else {
x = i;
}
return x;
}
}
console.log(findOne([3, 10, 3, 3, 3]));