Is there a way to create an infinite loop in the JavaScript code below? Currently, there is a timer set to run every 50 seconds, but I need it to continuously repeat every 50 seconds. My knowledge of JS is very limited, and while some parts of the code were explained to me, I still have a vague understanding of what's happening.
// An array that will be used later at line 30 and line 35.
var classnames = ["one","two","three","four","five","six"];
// Utilizing a CSS3 selector for classes (".classname")
var elements = document.querySelectorAll(".ani");
setTimeout(function() {
for (var i=0; i<elements.length; i++) {
var element = elements[i];
// For example: elements[0] removes the class "one", elements[1] removes "two"
element.classList.remove(classnames[i]);
element.offsetWidth = element.offsetWidth;
// For example: elements[0] adds the class "one", elements[1] adds "two"
element.classList.add(classnames[i]);
}
}, (50*1000));