Skip to content

Instantly share code, notes, and snippets.

@sebringj
Last active April 9, 2021 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebringj/63a09f4a78d30a97125cfdfc45684081 to your computer and use it in GitHub Desktop.
Save sebringj/63a09f4a78d30a97125cfdfc45684081 to your computer and use it in GitHub Desktop.
finds first repeated value and returns index
const findRepeatedIndex = arr => [...arr].findIndex(function(item) {
this.lookup = this.lookup || {};
return this.lookup[item] && 1 || (this.lookup[item] = 1) && 0;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment