 Help with a Loop!

Hello there,

I am playing with a LOOP. Personal note, I didn't know they could crash your browser. That is a killer weapon!

I am trying to store two random numbers into two variables, and compare them until they match so the loop is broken. Something is missing though.

This is the start. I've tested this and it should work:

var upper = 20;
var attempts = 0;
var random = getRandomNumber(5);

function getRandomNumber(upper) {
return Math.floor( Math.random() * upper ) + 1;
}

while (random !== getRandomNumber(upper) ) {
document.write("This is the first random number " + random + " and this is the second " + getRandomNumber(upper)+ " random number <br>")
;
attempts = attempts + 1;
}

document.write("<p> The random number was " + random + "</p>");
document.write("<p> It took the computer " + attempts + " attempts to guess it</p>");

Now, I do not know what's the next step. I tried creating another variable that pulls content from the same function, named "var TwoRandom = getRandomNumber(15)", but it doesn't work.

I also duplicated the function, named it differently, and created another variable to store its result. It doesn't work.

The idea that I have in mind would be something like that. If you play it, it goes into an infinite loop, so I do recommend tweaking this before.

var attempts = 0;
var random = getRandomNumber(5);
var TwoRandom = getRandomNumber(15);

function getRandomNumber(upper) {
return Math.floor( Math.random() * upper ) + 1;
}

while (random !== TwoRandom ) {
document.write("This is the first random number " + random + " and this is the second " + Tworandom + "  random number <br>")
;
attempts = attempts + 1;
}

document.write("<p> The random number was " + random + "</p>");
document.write("<p> It took the computer " + attempts + " attempts to guess it</p>");

Any ideas on why this is not working out?  