I have this function to create a random 4 digit number
generateCode = function(){
var fullNumber = [];
var digit1 = Math.floor(Math.random() * 9) + 1;
var digit2 = Math.floor(Math.random() * 9) + 1;
var digit3 = Math.floor(Math.random() * 9) + 1;
var digit4 = Math.floor(Math.random() * 9) + 1;
fullNumber.push(digit1, digit2, digit3, digit4);
this.theCode(fullNumber.join("")) ;
}
But I need to create a 4 digit random number with no repeating digits. So "1234" or "9673" .... but not "1145" or "5668"
any help is mucho appreciated guys! Not sure on an efficient way to come at this
Aucun commentaire:
Enregistrer un commentaire