fabianmoronzirfas
7/24/2017 - 11:35 AM

playing with intervals

playing with intervals

let counter = 0;
let bool = false;

function intervalFunc() {
  console.log(counter);
  counter++;
  if(counter === 5) {
    bool = true;
    clearInterval(interval);
  }
}

let interval = setInterval(intervalFunc, 500);

console.log('after interval');
if(bool === true) {
  console.log('bool was true');
}