I have an array of possible colors in Javascript:
possibleColors = [
"#10ace3",
"#f26529",
"#c62328",
"#e53434",
"#ffba49",
"#99c24d",
"#7e1d1d"
]
Given a string (the person's name), I'd like to always pick the same color, randomly.
As an example:
"Sergio" would always return the first color.
"Daniel" would always return the fourth color.
etc.
Any suggestions on how to do this? Please don't take my example literally I just mean the same string should return the same color.
Aucun commentaire:
Enregistrer un commentaire