Skip to content

Instantly share code, notes, and snippets.

@juniorbird
Created April 24, 2018 00:39
Show Gist options
  • Save juniorbird/66e6f1afd652c05b086c21f47a345397 to your computer and use it in GitHub Desktop.
Save juniorbird/66e6f1afd652c05b086c21f47a345397 to your computer and use it in GitHub Desktop.
Get First Repeating Character Example
function getFirstRepeatingCharacter(someString) {
let len = someString.length;
let cache = {};
for (let i = 0; i < len; i++) {
let currentLetter = someString.charAt(i);
if (cache[currentLetter]) return someString.charAt(i);
cache[currentLetter] = true;
}
// no result
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment