jeudi 19 mai 2022

Javascript Pick a random number between 4 values [closed]

I need to get a random number 3 or 5 or 7.

This is what i got so far:

let array = [3, 5, 7]
let id = Math.floor(Math.random() * 3)
console.log(array[id])

I want to know, if there are way to do this without creating an array?

Thank you.




Aucun commentaire:

Enregistrer un commentaire