How to ensure that when the number of pictures changes, the code does not need to change to achieve the function.

is that my current code is a little verbose, how can I change it so that I can add pictures in the future, but there is no need to change the code. I probably know how to use length, but I don"t know how to do it

.

var imgs = ["1.jpgrecords," 2.jpgrecords recorder 3.jpg"];

// 
var index = 0;
function setImage(imgCount){
    index += imgCount;
    if (index > imgs.length) {
          index = imgs.length;
    return;
    }
if (index < 0) {
        index = 0;
    return;
}
      

document.getElementById("img1").setAttribute("src", imgs[(index) % 3]);
document.getElementById("img2").setAttribute("src", imgs[(index + 1) % 3]);
document.getElementById("img3").setAttribute("src", imgs[(index + 2) % 3]);

}
function myFunction ()
{

Mar.02,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eaf6fc-2256.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eaf6fc-2256.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?