If I have a dynamic array with 40 elements that changes on every render, how can I loop through the array and return 4 groups of elements, each containing 10 items without any repetition? I want to style these objects in the array using a parent flex container with 4 div elements set to flex:25%, and the li elements as children. How can I achieve this using JavaScript when the images are not static?