Created
May 10, 2016 16:48
-
-
Save jweinsteincbt/c37e0c58c72cde71615feeee2178230b to your computer and use it in GitHub Desktop.
Java hashCode in JavaScript
This file contains 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
function hashCode(str) { | |
for(var i=0, total=0, len=str.length; i < len; ++i) { | |
total += str.charCodeAt(i)*Math.pow(31,(len - i - 1)); | |
}; | |
return total; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment