function loeWord() { var wordlist = ["health", "environment", "security", "communication", "people",]; var target = document.getElementById("word"); function getRandomInt(max) { return Math.floor(Math.random() * Math.floor(max)); } function setWord() { target.innerText = wordlist[i%wordlist.length] i += 1; } var i = getRandomInt(wordlist.length); setWord() setInterval(setWord, 5000) }; loeWord();