Generate a random number from a range min - max numbers how do?

@ulrich @Timo @thecoder2012 @Plankton

What i can do a random javascript to generate a random number from 50 to 100 ?

I need to set min value and max value.

With executeScript_Sandbox i can genererate a randon number from 0

return Math.floor(Math.random()*11)

Random number between 0 and 10

How can I convert this to have a min value to start and a max value to choice random numbers ?

Thanks

return Math.floor(50 + Math.random()*50) => random number between 50…100

1 Like

Working like a charm, thanks

Hello! I´m trying to generate a random number for the pause command. Between 3000 and 5000 (3 and 5s) for example. Is it possible by doing it in the target directly?

Thanks

Here the solution

{
  "Name": "Random",
  "CreationDate": "2021-7-21",
  "Commands": [
    {
      "Command": "executeScript_Sandbox",
      "Target": "var letters = ['3000','4000','5000'];  var string = '';  for(var i = 0; i < 1; i++){string += letters[parseInt(Math.random() * 3)]}; return string;",
      "Value": "v1",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "Random Value Is ${v1}",
      "Value": "#shownotification",
      "Description": ""
    }
  ]
}
1 Like