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);
3 Replies
Baptiste
Baptiste12mo ago
Yes
drippingfist
drippingfistOP12mo ago
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;

Did you find this page helpful?