I am attempting to display each word of a given text string on the screen at 60-second intervals. After some trial and error, here's what I have come up with:
let text = "Aliquam bibendum nulla et ligula vehicula semper. Nulla id posuere lorem, ac dignissim nunc. Quisque leo lorem, fringilla non ante ac, lobortis auctor leo. Fusce sit amet nibh vitae augue convallis iaculis eget ac erat.";
let mainId = document.getElementById("main");
function showWords() {
// Display words one by one.
let textArray = text.split(" ");
for(let i = 0; i < poemArray.length; i++) {
mainId.textContent = poemArray[i];
}
}
I understand that I need to utilize the setInterval() method in this scenario, but I am unsure about the correct way to implement it. I have attempted placing the entire for loop within the function parameter of setInterval() and even tried putting the code inside the for loop itself as the function parameter, but nothing seems to be working.