Created
          April 29, 2020 08:23 
        
      - 
      
- 
        Save sandrabosk/7392010a8314527745921f9eedbf3a11 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // ************************************************************************************ | |
| // https://www.codewars.com/kata/54f9f4d7c41722304e000bbb/javascript | |
| // Find the first character that repeats in a String and return that character. | |
| // firstDup('tweet') => 't' | |
| // firstDup('like') => undefined | |
| // This is not the same as finding the character that repeats first. In that case, | |
| // an input of 'tweet' would yield 'e'. | |
| // ************************************************************************************ | |
| function firstDup(str) { | |
| return str | |
| .split('') | |
| .filter((elem, i, arr) => arr.indexOf(elem) !== arr.lastIndexOf(elem))[0]; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment