JSFiddle - React, Tailwind, and code Playground
HTML
<h1 id="hi">Hi!</h1>
JavaScript
//create a collection
var myFont = [ "times", "helvetica", "verdana", "georgia"];
//record the last index used
var lastIndex;
setInterval(function(){
//pick a random number within the collection's range
// make sure it's not the same as the last one used
do{
index = Math.floor(Math.random() * myFont.length);
} while(lastIndex === index);
// record the font used
lastIndex = index;
//set the font
document.getElementById('hi').style.fontFamily = myFont[index];
}, 500);