I have this sample:
CODE JS:
for (var i=0; i < 5; i++) {
var number = 1 + Math.floor(Math.random() * 20);
console.log(number);
}
I want to generate numbers between 1 and 20 but with the following restrictions:
- The numbers should not be duplicated
- Exclude the first and last numbet (1,20)
- The difference between the generated numbers must be at least 3 (ex: 4, 7,10 etc)
Can you please give me some tips on how I could do this?
A few simple examples would help me.
Thanks
Aucun commentaire:
Enregistrer un commentaire