JShaman,
возможно вы хотели так ...
const repeat = (arr, wild) => {
let current, cut = [];
for(a of arr) {
if(a === wild || a === current) cut.push(a);
else if(current === void 0) cut.push(current = a);
else break;
}
return cut
}
let arr = [3, 10, 3, 3, 10], wild = 10;
console.log(repeat(arr, wild))