You’e got the right idea…

I wouldn’t use a single text… but rather an array (list) of texts (strings).

Then use the ‘reduce’ method on the array to iterate over them and count the occurrence of each.