Changing value of first loop in a for loop
I'm looping through an array of images and adding them to a carousel. The first image in the carousel needs to have an "active" class, but the rest needs to be without it. Currently my code looks like this
How do i make the first loop have active and the rest not?
2 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I'd argue that the code duplication is worse than the miniscule performance hit of a simple conditional check a handful of times for a loop
cause then if you need to change anything about anything else, you need to remember to do it twice