I am trying to set an interval when some code runs but only need to do it based on the number of elements there are. Here’s a quick example:
5 total elements
Run code once every 20 seconds for each element that is found.
Can someone please give me a basic example how to do this using plain JavaScript? Everything I have tried just executes all of the code at once instead of doing one element at a time.
let’s suppose you’re talking about elements of an array or a DOM collection
Edit:
if you cannot reverse the array for any reason just use next version