狂飙的蜗牛_1
//可以这样写
var arr = ["a","b","a","b","b"];
var map = {};
for(var i = 0;i<arr.length;i++){
if(typeof map[arr[i]] === 'number'){
map[arr[i]]++;
}else{
map[arr[i]] = 0;
}
if(map[arr[i]] !== 0){
arr[i] = arr[i] + "_" + map[arr[i]];
}
}
console.log(arr); //["a", "b", "a_1", "b_1", "b_2"]