How to merge two function in the code.

how can two function be merged into one
var imgs = ["1.jpgstamp," 2.jpgprecinct 3.jpg`];

// 
var imgCount = 1;
var index = 0;
function rightClick(){
    
    index -= imgCount;
    
    
    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 leftClick(){
    index += imgCount;
    if(index > imgs.length){
        index = imgs.length;
        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]);
    
}
Mar.02,2021

var imgs = ['1.jpg', '2.jpg','3.jpg'];

// 
var index = 0;
function keyClick(setT){//setT=1-1 
    index += setT;
    if(index < 0){
        index = 0;
    }
    if(index > imgs.length){
        index = imgs.length;
    }
    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]);
}
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-1e51301-45128.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-1e51301-45128.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?