Coding Challenge Practice – Question 62
The task is to write a function that finds the first duplicate given a string that might contain duplicates. The boilerplate code function firstDuplicate(str) { // your code here } Declare a variable to keep track of every character that is seen const seen = new Set() As soon as a character that has been…