I need to loop through the function switch_tiles so the function will run as switch_tiles(1); switch_tiles(2); etc... but it needs to be i++ every 5 seconds. I've tried putting the interval inside the loop but that didn't help either. Also, after i = 5 I want it to reset.
window.setInterval(function(){
for(var i = 1; i < 5; i++){
switch_tiles(i);
}
}, 5000);
This is all the function does so that's not too important to the question. Just added for context.
function switch_tiles(n){
var last = $('.active').attr('id');
$('#'+last).removeClass('fas');
$('#'+last).removeClass('active');
$('#'+last).addClass('far');
$('.active_tile').fadeOut();
$('#tile_' + n).fadeIn();
$('#circle_' + n).removeClass('far');
$('#circle_' + n).addClass('fas');
$('#circle_' + n).addClass('active');
}