1)
function run() {
var array = document.getElementById("data").value.split(",");
var result = {};
array.sort();
for(var value in array) {
var index = array[value];
result[index] = result[index] == undefined ? 1 : result[index] += 1;
}
var table = [];
for(var value in result) {
table.push("<tr><td>" + value + "</td><td>" + result[value] + "</td></tr>");
}
document.getElementById("output").innerHTML = "<table border='1'><tr><td>값</td><td>중복개수</td></tr>" + table.join("") + "</table>";
}
2)
var array = [5,3,4,2,3,4,5,1,2,3,3,2,1];
var result = {};
array.sort();
for(var value in array) {
var index = array[value];
result[index] = result[index] == undefined ? 1 : result[index] += 1;
}
for(var value in result) {
alert(value + "의 중복 개수 : " + result[value]);
}