美文网首页
duplicate array

duplicate array

作者: Time_Notes | 来源:发表于2020-07-19 05:28 被阅读0次

function dupicateWord(arr) {

    let obj= {}

    arr.forEach(ele=>{

        if(!Object.keys(obj).includes(ele)) obj[ele]=false

        else obj[ele]=true

    })

    return obj

}


function duplicatedWord(chars){

    var map=new Map();

    for(var i=0;i<chars.length;i++){

        if(map.has(chars[i])) map.set(chars[i],'true');

        else map.set(chars[i],'false');

    }

    return map;

}

相关文章

网友评论

      本文标题:duplicate array

      本文链接:https://www.haomeiwen.com/subject/ciikkktx.html