The problem is that now, loop shows only last value of array which is 'o'
const h2 = document.querySelector('h2');
const title = document.querySelector('h1');
const word = ['h', 'e', 'l', 'l', 'o'];
function loop() {
for(let i = 0; i < word.length; i++) {
window.setInterval(() => {
console.log(word[i]);
title.textContent = word[i];
}, 1000)
}
}
loop();
<h1 /><h2 />