SOURCE

let array = [[1, 2], [2, 3], [4, 5], [10, 12], [5, 8], [15, 17], [13, 15],]
// const result = [[1, 3], [4, 8], [10, 12], [13, 17]]

function getCombineList(array) {
    const cache = {}
    if (!(Array.isArray(array))) { return }
    array.forEach(item => {
        const start = item[0]
        const end = item.slice(-1)[0];
        if (!cache[start] && !cache[end]) {
            cache[end] = start
            cache[start] = item
        } else if (cache[end]) {
            const info = cache[end]
            info.splice(0, 1, start)
        } else {
            const attr = cache[start];
            const info = cache[attr]
            info.splice(1, 1, end)
        }
    })
    return Object.values(cache).filter(info => {
        return Array.isArray(info)
    })
}

const result = getCombineList(array)
console.log('log...result', result)
console 命令行工具 X clear

                    
>
console