return first duplicates js code example
Example: first duplicate javascript
function firstDuplicate(a) {
let data = [];
for (dup of a) {
if (data[dup]) {
return dup
} else {
data[dup] = dup
}
}
return -1
}