zerokilled quiero agradecerte tu compromiso y dedicación con este problema. De nuevo no puedo darte karma, que es lo que te mereces, ya que según las normas del foro, no esparzo el suficiente.
Parece que esta mañana se me encendió la luz. Pensando en como acceder a los valores de cada elemento del objeto, me vino
cantidad[arr_limpio[j]], y resulto. Aquí dejo el script por si a alguien le puede ayudar
Código javascript
:
Ver original<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="http-equiv" content="Content-type: text/html; charset=UTF-8"/>
<script type="text/javascript">
var arr_limpio = [];
var val_eliminados = [];
Array.prototype.EliminarRepetidos = function () {
var cantidad = {};
for(var i = 0; i < this.length; i++){
if(!(this[i] in cantidad)) {
cantidad[this[i]] = 0;
arr_limpio.push(this[i]);
cantidad[this[i]]++;
} else {
val_eliminados.push(this[i]);
cantidad[this[i]]++;
}
}
var repeticiones = "";
for (j=0; j < arr_limpio.length; j++) {
repeticiones +="El elemento " + arr_limpio[j] + " se repite ------ " + parseInt(cantidad[arr_limpio[j]]-1) +" veces\n"
}
alert("Arreglo Original: " + array.toString() + "\nArreglo Limpio: " + arr_limpio.toString() + "\nValores Eliminados: " + val_eliminados.toString() + "\nCantidad de veces que se repite cada elemento\n=======================\n" + repeticiones)
}
function ContarRepetidos(valores) {
var val = valores;
array = val.split('');
obj = array.EliminarRepetidos();
}
</script>
</head>
<body>
<a href="javascript:void(0);" onclick="ContarRepetidos('1283434536473846390');">Ver</a>
</body>
</html>