I have a table of action logs in my application. I want to assign rows a random colour based on the sessionID of that entry to help see patterns/grouped actions.
I have this so far:
console.log(stringToColorCode('mj3bPTCbIAVoNr93me1I'));
function stringToColorCode(str) {
return '#'+ ('000000' + (Math.random()*0xFFFFFF<<0).toString(16)).slice(-6);
}
However I need to replace Math.random() with my string-integer, are there any techniques for converting a string to a random number that remains consistent with the random string?
0xFFFFFF<<0
the same as0xFFFFFF
?(parseInt(parseInt('mj3bPTCbIAVoNr93me1I', 36).toExponential().slice(2,-4)) & 0xFFFFFF).toString(16).toUpperCase(); // "32EF01"