How to make it easier?

how can I write the two ends marked in red? for example, if I add ten more pictures, I don"t need to change too much. It will be troublesome if I add ten more pictures.

Mar.02,2021

use for loop

for(let i = 0; i < 10; iPP) {
  document.getElementById('img' + i).setAttribute('src', img[(index + i) % img.length]);
}
Menu