const outputElement = document.getElementById('output');
const textArray = ['First text message.', 'Second text message.', 'Third text message.'];
let currentIndex = 0;
function displayNextText() {
if (currentIndex < textArray.length) {
// Replace the entire content with the current text
outputElement.innerHTML = textArray[currentIndex];
currentIndex++;
// Schedule the next text to be displayed after a delay (e.g., 2 seconds)
setTimeout(displayNextText, 2000); // 2000 milliseconds = 2 seconds
}
}
// Start the display sequence
displayNextText();