获取最小数字

function getMinNum(str = '2354363463',n = 2){
    let arr = [];
    let splitArr = str.split('')
    for(let i = 0;i < splitArr.length - n + 1;i++){
        let item = splitArr.splice(i,n);
        arr.push(Number(splitArr.join('')));
        splitArr.splice(i,0,...item);
    }
    return Math.min(...arr);
}

  

posted @ 2021-03-16 21:45  671_MrSix  阅读(61)  评论(0编辑  收藏  举报