jeudi 25 mai 2017

non-repetitive random number picker

I'm trying to create a non-repetitive random number picker, can anyone please point out what went wrong with it? thanks

var resultArray = [];

function pickRandom(){
  var min = parseInt(document.getElementById("min").value);
  var max = parseInt(document.getElementById("max").value);
    var result = Math.floor((Math.random() * max) + min);

    resultArray.push(result);

  for (var i = 0; i < resultArray.length; i++){
     if(resultArray[i].includes(result))
     {
      pickRandom();
     } else {
      document.getElementById("result").value = result;
     }
  }
}




Aucun commentaire:

Enregistrer un commentaire