DEV Community


Discussion on: And then the interviewer asks, "Can you do this with less code?"

elmuerte profile image
Michiel Hendriks • Edited
const duplicateCount = a => a.length - new Set(a).size;

And now with a meaningful name. Because, what does duplicateCheck mean, that is has, or does not have duplicates. For the boolean version hasDuplicates would be the better name.

Forem Open with the Forem app