Javascript code not working

I’m not even really sure what I’m making, just trying to get some code out.

I’m trying to make each box light up individually one by one in a line then when it reaches the end on the left it turns back and goes the other way.

I think my issue is it’s looping through everything in the for loop to quickly I’ve tried numerous different ways to set a delay in the for loop but nothing has worked.

Try running ‘Analyze JS’ in the JS portion of codepen. It suggests a couple of things you may want to look at.

You’re almost there. By using setTimeout() you’re delaying execution of color(arr[i]), but the problem is you’re delaying all of them by the same amount of time.

There is not much of an option for a delay between each interval in stead it delays then executes. I tried a self invoking function but nothings working…

never mind I did it. It’s updated on code pen now thanks

Here’s a bit shorter version: