Random number generator with a range: how to exclude values based on participant response? | XM Community
Skip to main content

Hello, I am attempting to construct a question and answer series wherein the participant states a percentage between 0 and 100, and then a random number generator gives a percentage. We're hoping to make certain that the RNG does not repeat the same percentage as the participant response. Is there code to exclude the participant response percentage from the range that the RNG could output?
Thanks.

Using JS, you can make sure that the random number is different from the input number by using a while loop:
var rng;
while((rng=Math.round(Math.random() * 100)) == inNum);


Leave a Reply