Brandon Brandon - 1 year ago 66
Javascript Question

why isnt this setInveral function working?

I cant figure out what I'm doing wrong

function countNum(){
let num=0;
function inner(){
num++
console.log(num);
}
}

setInterval(countNum,1000)

Answer Source

You are defining function but not calling

function countNum(){
     let num=0;
     function inner(){
            num++
            console.log(num);
               }
              inner();/////////////////////////////
          }

 setInterval(countNum,1000)