https://discord.gg/botpress logo
How do I output my variable for weight as its valu...
# 🤝help
l
The bot is outputting the message "message:"Convert input 45 kg -> 99.20809890826999 lb"" but I simply want it to output 99.21 rounded to two decimal places. Is there a way I can get around this? https://cdn.discordapp.com/attachments/1261007110544818226/1261007110737760316/image.png?ex=669163e3&is=66901263&hm=1eb481d23eb50e1468df429edd370e4e489b20b83b6642da4615a23a3e983011&
s
Hi, I apologize but I don't understand your message. What I assume I can see is the workflow.Weight which is the object. So you output in text card {{workflow.Weight.value}}
l
omg thanks that worked, but is there a way i can round it? should i use the code function to round?
I want to be able to round the value that I get to two decimal places or even no decimal places if possible
nvm i got it thanks so much for your help
e
You can use Code Card with something like workflow.anyVar = Number(event.preview).toFixed(2) Here the anyVars has to be where you want to store your result. So replace it with your var name Number will convert the String into a number. In my case I type directly usign a Raw Input Card, that's why I use event.preview to get the user last input. Finaly, the important part, toFixed(2) will round your number to 2 diget as you need. It round it, don't just cut it. so 19.56799 will be 19.57 Hopa that help