Assuming I have an array:
var arr = ["YB | Yazmn", "PdH | Soul's", "YB | Infx," "PdH | Jvoo!", "YB | FK@2"];
In this array they are just strings, and in my context (what I want to achieve) what is before the |
are ' clans ', in this case there are only 2 clans:
YB
PdH
As I can tell, with a fixed-length array of 10 values , which is the most repeated clan ?
Without expresiones regulares
? or are they necessary in this case? I'm stuck
Also the clans are added by the same players.
var clanes = [];
var b = document.getElementById('registroClan').value;
clanes.push(b.toString());
/* y se me ocurré recorrerlos y ***si coincide*** algun clan con el array ''arr'' se le suma 1 a la variable que se crearía según el clan ingresado.
*/
for (var i=0; i<arr.length;i++) {
/* Un problema más es que deberia crear una variable con el nombre del clan, osea si el jugador ingresa el clan llamado 'YB' además de ingresar al array se crearía una variable para así poderle sumar 1 si es que se repite en un futuro.
*/
variableClan = 0; // <== Solo ilustrativamente, ya que el usuario crearía la variable al introducir su clan y siempre se le asignaria un valor de 0 al comienzo.
if(arr[i] == clanes[i]) variableClan += 1;
}