Created
April 19, 2017 11:50
-
-
Save tiagodealmeida/635bf0eb16e3556dc705fd4e0f1236e6 to your computer and use it in GitHub Desktop.
firstRepeatingLetter function code challenge
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
var str = 'tyiyrHFTH'; | |
function firstRepeatingLetter(string) { | |
var exp = /(.).*(\1)/g; | |
var res = exp.exec(string); | |
return res ? res[1] : string.length ? string[0] : null; | |
} | |
console.info(firstRepeatingLetter(str)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment