Repeat random number

0

How could you make a condition that shows you a certain message after a certain random number is repeated 7 times? For example:

  var gana = localStorage.getItem('j1');
  if (gana == c) {
      alert("Gana jug1");
  }

I have that code that in the variable wins you choose a number already entered and saved in localstorage as j1 and if the random number is the same as the entered one it shows you the alert but I do not know how to do it to show me that alert when such number was repeated 7 times and not just one that is like I have the code.

 $('#boton-guardar').click(function(){       
   var num= $('#num1').val();

    if (num > 1 && num <13) {
    localStorage.setItem('j1', num);
   num= $('#num1').val('');
   var numero1 = localStorage.getItem('j1');
    $("#numj1").html(numero1);
} 
else{
    alert("Ingresa un numero valido")
    }     
});   

The entered value is saved as j1 in localStorage.

    
asked by Jose Miguel Ortiz 31.10.2018 в 20:38
source

1 answer

1

create an array with example positions if the maximum number is 7

var m_numero =7;
var array=[];
var numero_ganador = 9;
if(array[numero] == undefined){
   array[numero]=1;
}else{
  array[numero]= eval(array[numero])+1;
}

if (array[numero_ganador] != undefined && array[numero_ganador] == m_numero){
  alert("el numero se repitio: "+m_numero);
}
    
answered by 31.10.2018 в 21:25