Calculate the color associated with the text

+ a small optimization at the beginning of script.js