I was playing with javascript. I was trying to change color every second without use css. But it only use last item of array. How can I fix this?
const h1 = document.getElementsByTagName("h1")[0];
color=["green","orange","blue"]
const myTimeout = setInterval(function() {
for(i=0;i<color.length;i++){
h1.style.color = color[i]
}
}, 1000);
New contributor
vdt2938 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.