mardi 13 avril 2021

Generate a random number that can be used in a function on JS [duplicate]

I want to generete a random number between 1 and 6 that can be used in functions, for example the paramether of 'randomlySelectAnSlot', i already tried to use:

let randomNumber = Math.floor((Math.random() * 6) + 1)

But didn´t work either is undefined or keeps trowing the same number.

Here my code friends.

slots = [slotOne, slotTwo, slotThree, slotFour]

function randomlySelectAnSlot (slot) {
console.log('Here i want a random slot either SlotOne, SlotTwo...etc')

}




Aucun commentaire:

Enregistrer un commentaire