function foundStr(str){
var arrResult=null;
if(typeof str === 'string'){
for(let i of str){
if(str.indexOf(i) == str.lastIndexOf(i)){
arrResult = i;
break;
}
}
if(arrResult!=null){
console.log("result:",arrResult);
}
else{
console.log("沒有符合的字符");
}
}
else{
console.log('傳入的不是字符串');
}
}
var str = 'cbaacfdeaebb';
foundStr(str)
如有考慮不周的地方還請提出指正!