Working with Imacros javascript, need random variables except one value

只愿长相守 提交于 2020-01-07 09:28:28

问题


I am working with Imacros, and using this to get random values from 0 to 5, for Var1. Is there any way i can block out "4" out of the pool, as "4" is not needed.

SET !VAR1 EVAL("var randomNumber=Math.floor(Math.random()*5 + 0); randomNumber;")

Alternatively, is there any way i can define Var1, to be random from values: 0,1,2,3,5 ?


回答1:


How about this?

SET !VAR1 EVAL("var randomNumber=Math.floor(Math.random()*4); randomNumber==4?5:randomNumber;")


来源:https://stackoverflow.com/questions/24231744/working-with-imacros-javascript-need-random-variables-except-one-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!