title: Limiting the setInterval function?
body: <pre><code> function greet(name) {
              console.log('Hello Good Morning ' + name );
          }
  
          
          // let timeout = setTimeout(greet, 3000 , &quot;Alapottra&quot;);
          // console.log(timeout);
  
          // clearTimeout(timeout);
  
         
  
         let interval =  setInterval(greet , 2000 , 'Jhon');
          
         let count = 0 ; 
         if (count &lt; 4){
             console.log(interval);
             count++
         }else{
             clearInterval;
         }
  </code></pre>
  <p>How to a limit to the interval function like I want it to run 5 times and then stop , I tried using a while loop as well as for loop but it seems like it has no effect whatsoever</p>