Hey, I've just started learning JavaScript and I'm making a little script that generates two numbers, the first number stays the same but the second number gets regenerated if it doesn't match the first number.
Here is my script:
function randomNumberMatcher(){
    $(document).ready(function(){
     var number1 = Math.floor(1000000*Math.random());
     var number2 = Math.floor(1000000*Math.random());
     var count = 0;
     $("#box").append("Number to match:[" + number1 + "]<br /><span id='count'></span>");
     function newNumber(){
      number2 = Math.floor(1000000*Math.random())
      count ++;
      $("#count").html("Number of tries:[" + count + "]<br /><br />");
      $("#box").append(number2 + "<br />");
      check();
     }
     function check(){
      if(number2 != number1){
       newNumber();
      }
     }
     check();
    });
};
At the moment when i run the script all it does is hang until it has finished and then it prints the data to the screen, this however is not what I intended it to do, what I want is it print the data to the screen in real time so that I can see the different numbers it is generating appear on the screen one by one.
How would I make it do this?
note: I'm also using the jQuery library.