Answers for "first repeating element in an aarray"

1

first duplicate javascript

function firstDuplicate(a) {
    let data = [];
    
    for (dup of a) {
        if (data[dup]) {
            return dup
        } else {
            data[dup] = dup
        }
    }
    return -1
}
Posted by: Guest on October-25-2020

Code answers related to "first repeating element in an aarray"

Code answers related to "Javascript"

Browse Popular Code Answers by Language