function copyWoorld(str) { var arr = str.split(''); var newArr = []; var arr2 = []; arr.forEach(function (ele,index,arr) { if( ele == ',' || ele == '。') { }else { if(newArr.indexOf(ele)<0){ newArr.push(ele); }else{ arr2.push(ele+ele); } } }); return arr2; } console.log(copyWoorld('独坐常忽忽,情怀何悠悠。山腰云缦缦,谷口风飕飕。'));