Quick actions

cmd+k|ctrl+k

Navigation

Languages

FirstRecurringChar

Snippet info

Language

JavaScript

Visibility

public

Author

coolheart08

Created

2020-11-09T09:44:35Z

Updated

2020-11-09T09:44:35Z

const arr1 = [2,1,1,2,3,3,1,3]


const firstRecurringChar = (anArr) => {
    let res;
    let recurred = {};
    for(const elem of anArr){
        if (recurred[elem]) return elem 
        else recurred[elem] = true
    }
    
    return res
}

console.log(firstRecurringChar(arr1));
INFO