Q:

Stop If and Else stetment on Counting

I want to create the page that show loading and than show the random number with time, but the problem is when loading switch to random number, that random number change again to loading (looping).
here is my code :
<div class="spinner" id="box1">
  <div class="double-bounce1"></div>
  <div class="double-bounce2"></div>
</div>
<div class="suhu" style="display:none" id="box2">
 <span style="color: #E74C3C; font-size: 30px; text-align: center;">
    Suhu Anda : </span><span id="decimalgenerate" style="font-size: 30px;"></span><span style="font-size: 30px;">&#8451;<br/></span><span style="color: #E74C3C;"></span>
</div>

and here is the JS code :
setInterval(function thing() {

      var b1 = document.getElementById('box1');
      var b2 = document.getElementById('box2');

      if(b1['style'].display == 'none')break; {
        b1['style'].display = 'block';
        b2['style'].display = 'none';

      } else {
        b1['style'].display = 'none';
        b2['style'].display = 'block';

      }

    }, 7000);

A:

For stop interval use clearInterval
var myTime = setInterval(function thing() {

      var b1 = document.getElementById('box1');
      var b2 = document.getElementById('box2');

      if(b1['style'].display == 'none')break; {
        b1['style'].display = 'block';
        b2['style'].display = 'none';

      } else {
        b1['style'].display = 'none';
        b2['style'].display = 'block';
      }
    }, 7000);

and where you want
clearInterval(myTime)

Example:
var myTime = setInterval(function thing() {

      var b1 = document.getElementById('box1');
      var b2 = document.getElementById('box2');

      if(b1['style'].display == 'none') {
        b1['style'].display = 'block';
        b2['style'].display = 'none';
        clearInterval(myTime);
      } else {
        b1['style'].display = 'none';
        b2['style'].display = 'block';
      }
    }, 7000);

