Brandon Brandon - 27 days ago 8
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

You are defining function but not calling

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

 setInterval(countNum,1000)