0

I am looking for whole day about solution for this problem. So, my intention is to make something like a bingo numbers poping out. One after another. Now, problem I am experiencing is that always function is runned just once and I am getting 8 times same number. One after another. I am pretty much begginer with javascript so every help is appreciated.

var konjo = (i) => { 
  i = document.getElementById("testic").innerHTML +="<p> Brojic je " + x + "</p>";
 }
 var x = Math.floor(Math.random() * 49);
 for(j = 1; j < 9;j++)
 {
  function trs(bass){ 
   setTimeout(bass, 1000 * j);
  }
  trs(konjo);
 }
  
<!DOCTYPE html>
<html>
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
  <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
  <title>Bingac</title>

 </head>
 <body>
 
 <div id="testic"></div>
 
 </body>
</html>
Kumbra
  • 123
  • 4
  • 1
    This is all you need : `for(j = 1; j < 9;j++){ setTimeout(function(){ document.getElementById("testic").innerHTML +="

    Brojic je " + Math.floor(Math.random() * 49); + "

    "; }, 1000*j); }`
    – Boo Jun 24 '18 at 13:58
  • So, bascily all what needs to be done is to put everything into one function. Amazing! :D thank you – Kumbra Jun 24 '18 at 14:05
  • The lesser the code, better. – Boo Jun 24 '18 at 14:06

0 Answers0