Random Number

May 02, 2022

Let me start out by saying I know just enough JavaScript to get by... I have developed a quiz where the user competes in a game with the computer.  If the user gets the answer wrong the computer gets to "guess."  I used a random number generated from SL.  My trouble is that I don't want the computer to guess the same answer as the user.  I have tried several combinations in JavaScript but just can't get it to work.  Your help is greatly appreciated!  This is my code: 

var player=GetPlayer();

var i=player.GetVar("PlayerResponse");
var y=player.GetVar("RandumNumber");

 
while (y = i) {
  var randomnumber = Math.floor((Math.random()*4)+1);
  var i = randomnumber;
}

player.SetVar("RandumNumber",randomnumber);
player.SetVar("worked",y);

2 Replies