p5:
https://editor.p5js.org/CodingMcnugget/sketches/QTSYYJNFG
Modify from  p5.js TF-IDF sketch
My code will determine the color grayscale of the text based on the frequency of the text appearing in the text. Instead of looping through all the text, I used JavaScript‘s Reduce function to calculate the frequency directly.