编辑代码

function convert(str){
    if(typeof str!=='string'){
        console.log('输入的类型不是字符串!')
    }
    let arrStr = str.split('_')
    let newStr=''
    arrStr.map(item=>{
        if(item){
            newStr+=item.substr(0,1).toUpperCase()+item.substr(1)
        }
    })
    return newStr
}

var arr='_abc_ghe_nb_w_'
console.log(convert(arr))