146
Views
6
Comments
Solved
Random number JS

Hi,


Im trying to generate a random number using the JS code:


$parameters.IncdiceDrawn = Math.floor((Math.radom() * $parameters.Quantity));


But when I open the page on the web screen And click the button to the action, the follow message appear: (error) Math.random is not a function


Somebody now any solution.


Thank you.


math.random.jpg
2021-06-02 20-50-04
Márcio Carvalho
Solution

The problem here is radom, which should be random().

$parameters.IncdiceDrawn = Math.floor((Math.random() * $parameters.Quantity)); 

UserImage.jpg
Bárbara Fernandes

Thank you so much Márcio.

2024-11-03 07-30-05
Manoj Kumar C

Hi Bárbara,

You can refer this component for randomize number generation 

https://www.outsystems.com/forge/component-overview/677/randomizer-number-generator


2021-06-02 20-50-04
Márcio Carvalho
Solution

The problem here is radom, which should be random().

$parameters.IncdiceDrawn = Math.floor((Math.random() * $parameters.Quantity)); 

UserImage.jpg
Bárbara Fernandes

Thank you so much Márcio.

2021-03-08 09-24-09
Rúben Meireles

Hi @Bárbara Fernandes 

I think you have a typo in "Math.radom()", do you meant "Math.random()"? :) 

Regards,

Rúben 

UserImage.jpg
Bárbara Fernandes

Thank you so much Ruben!

2018-05-15 08-41-11
Davide Periquito

Hey,


I believe you will find this forge component very useful (most of these things are already covered there):

Reactive Utilities - Documentation | OutSystems

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.