+ 1
How to create a name picker using Math.floor(Math.random()*5), and when that happens, the random number will be used to pick a
a name, like #randomNumber pick from names, if the random number is 3 it will pick from the arrays.? sorry for my bad english😂
1 Réponse
+ 1
let choices = [/* Your array of names /*]
// Random choice from 0 to 4
choices[Math.floor(5 * Math.random())];
// Random choice from 0 to n - 1
choices[Math.floor(n * Math.random())];
// Random choice from min to max
choices[Math.floor(Math.random() * (max - min + 1)) + min;]
You can declare a function to take choices as the argument.