Interview Prep Quiz Practice
Active Recall Drill Session
← Exit SessionQuestion 1 of 1
easyInterview Prep
What does this function return for input ['a','b','a','c']?
code
function firstRepeat(arr) {
const seen = new Set();
for (const x of arr) {
if (seen.has(x)) return x;
seen.add(x);
}
return null;
}
firstRepeat(['a','b','a','c']);