Created
January 29, 2015 02:56
-
-
Save smithamax/57c2d330336950bd26ad to your computer and use it in GitHub Desktop.
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
function Colourizer (colors) { | |
this._colors = colors; | |
} | |
Colourizer.prototype.getStringColor = function (str) { | |
var letters = str.split(''); | |
return this._colors[letters.reduce(function (n, c) { | |
return n + c.charCodeAt(0) | |
}, 0) % this._colors.length]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment