Javascript/指定した要素の位置までスクロール

code
const element = document.getElementById("jsnap");  

let num = 0;   

function susumu() {
    if(num + 1 < element.children.length) {
        let child = element.children[num + 1];  
        child.scrollIntoView({  
            behavior:"smooth",  
            block:"nearest",  
            inline:"nearest",  
        });  
        num++;  
    } else {
        return;
    }
}

function modoru() {
  if(num - 1 >= 0) {
    let child = element.children[num - 1];  
    child.scrollIntoView({
        behavior:"smooth",  
        block:"nearest",  
        inline:"nearest",  
    });  
    num--;  
    } else {
        return;  
    }
}