Markov Chain in p5.js

Hello,

I am interested in creating a project that uses a markov chain. I have edited this example a bit: p5.js Web Editor.

Whereas right now the code features a generate button and produces a list, I would like for a screen to show only one result at a time, for a few seconds, and then be replaced by a new string. Ideally, this can be set off by sensors using arduino but that’s further down the line. Thanks for any feedback!