Skip to content

Instantly share code, notes, and snippets.

@tiagodealmeida
Created April 19, 2017 11:50
Show Gist options
  • Save tiagodealmeida/635bf0eb16e3556dc705fd4e0f1236e6 to your computer and use it in GitHub Desktop.
Save tiagodealmeida/635bf0eb16e3556dc705fd4e0f1236e6 to your computer and use it in GitHub Desktop.
firstRepeatingLetter function code challenge
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