SOURCE

const func = (array)=>{
    let noneArr = []
    array.forEach(item => {
        for(let i=0;i<array.length;i++){
            for(let j=0;j<array.length;j++){
                if(item == array[i] + array[j]) noneArr.push(item)
            }
        }
    })
    noneArr.sort((a,b) => {
        return b.length - a.length
    })
    let isHava = null;
    for(let i=0;i<noneArr.length;i++){
        if(i+1 >= noneArr.length) break;
        if(noneArr[i].length == noneArr[i+1].length){
            isHava = true
        }
    }
    // console.log(isHava)
    let indexArr = noneArr.map(item => {
        return array.indexOf(item)
    })
    if(isHava){
        let max = indexArr.reduce((item,next) => item > next ? item : next)
        return array[max]
    }else{
        return noneArr[0]
    }
}
//以下代码不要修改

var array1 = ['ac','ad','acad','aga','agaacad','sk','skacad','hasdjasnskss'];
var array2 = ['ac','ad','acad','aga','agaacad','skd','skdacad','hasdjasnsk'];

console.log(func(array1))
console.log(func(array2))
console 命令行工具 X clear

                    
>
console