АртемБМ,
let setIndex = up => i = (i + up + sliderItem.length) % sliderItem.length;
buttonRight.addEventListener("click", function () {
sliderItem[i].classList.remove("block");
setIndex(1);
sliderItem[i].classList.add("block")
})
buttonLeft.addEventListener("click", function () {
sliderItem[i].classList.remove("block");
setIndex(-1);
sliderItem[i].classList.add("block")
})