Share feedback, ideas and get community help

F
M
a
g
E

How can generate a random number variable from 0.1 - 9.9?

Can I execute javascript in the set variable logic? Like:

const randomValue = Math.random() * (9.9 - 0.1) + 0.1;
console.log(randomValue);
B
d
3 comments
Sorted. In case this is useful for someone else. Here's the random number generator between 11.3 and 12.5


function getRandomNumber() {
return new Promise((resolve) => {
const min = 11.3;
const max = 12.5;
const randomNumber = Math.random() * (max - min) + min;
resolve(randomNumber.toFixed(1)); // Rounded to one decimal place
});
}
const wait = await getRandomNumber();
return wait;
Add a reply
Sign up and join the conversation on Discord
Join