Last active
April 9, 2021 18:32
-
-
Save sebringj/63a09f4a78d30a97125cfdfc45684081 to your computer and use it in GitHub Desktop.
finds first repeated value and returns index
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
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