Log in
Log into community
Share feedback, ideas and get community help
View all posts
Related posts
Did this answer your question?
๐
๐
๐
Powered by
Hall
Inactive
Updated 3 months ago
0
Follow
How can generate a random number variable from 0.1 - 9.9?
How can generate a random number variable from 0.1 - 9.9?
Inactive
0
Follow
d
drippingfist
7 months ago
ยท
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
Share
Open in Discord
B
Baptiste
7 months ago
Yes
B
Baptiste
7 months ago
https://docs.typebot.io/editor/blocks/logic/set-variable
d
drippingfist
7 months 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;
Add a reply
Sign up and join the conversation on Discord
Join on Discord