title: Stop interval once console.log display undefined
body: <p>I have created an interval function to keep running my function over and over again, after dom is refreshed with new data , at certain point, my console.log will display undefined. how do we capture or stop interval at the point where my console.log states undefined. Is there a function we could use to capture when console.log is triggered with undefined message?</p>
  <p>Console.log</p>
  <pre><code>VM64:56         19
  VM64:56         18
  VM64:56         17
  VM64:56         16
  VM64:56         15
  VM64:56         14
  arc_all.js?v=5.1.3.0-1570239956:18     undefined display format making Product Design Risk NaN
  arc_all.js?v=5.1.3.0-1570239956:18     undefined display format making &lt;span data-dim=&quot;16&quot; data-dimidx=&quot;2&quot; class=&quot;crosstab-expand&quot;&gt;  &lt;i class=&quot;fa fa-plus-square-o&quot;&gt;&lt;/i&gt;&lt;/span&gt; NaN
  arc_all.js?v=5.1.3.0-1570239956:18     undefined display format making Anti-Competitive Conduct Risk NaN
  
  VM64:56         13
  ...
  VM64:56         0
  </code></pre>
  <p>To further elaborate my function, I have created this function, this function. function is working fine, I am unsure on what approach should I move towards in getting the message on console.log for undefined.</p>
  <pre><code> function auto_refresh(start_count) {    
               window.repeat = setInterval(function(){ 
                      start_count = start_count - 1;
                          console.log(start_count)
  
                  const request = $.ajax({ 
                   async : true,
                   success : function(){
                   setTimeout(customStyle(), 100)
                   },
                });
  
                  if (start_count &lt;= 0) {
                  //Will clear interval when timer is 0
                    window.clearInterval(window.repeat);
                  console.log('Inside the call function to be removed ' + window.repeat);
                }
  
               }, 1000);
            
              }
            
        //           // Call auto_refresh function and set 1 - 10 , e.g 10 will run interval for 10 seconds and =&gt; stop function ,
        //           // Bigger datasets , set to 30  - 150 or which is preferred 
                   auto_refresh(20)
  </code></pre>