function duplicateEncode(word) {
word = word.toLocaleUpperCase();
var strArr = word.split("");
var newStrArr = [];
for (var i = 0; i < strArr.length; i++) {
var num = 0;
for (var j = 0; j < strArr.length; j++) {
strArr[i] === strArr[j] && num++;
}
if (num > 1) {
newStrArr[i] = ")";
} else {
newStrArr[i] = "(";
}
}
return newStrArr.join("");
}
// 简洁写法
function duplicateEncode(word){
return word
.toLowerCase()
.split('')
.map( function (a, i, w) {
return w.indexOf(a) == w.lastIndexOf(a) ? '(' : ')'
})
.join('');
}