function consoleTest() {
setInterval(function(){
console.log('Hello World');
}, 1000);
}
$('#button').on('click', function(){
clearInterval(consoleTest);
});
consoleTest();
I created a simple app when I click the button it will stop/pause the interval. I know how to make it work I just need to declare a variable outside the function and contain there the setInterval, now I am just confused why clearInterval won't work if I call it via a function, somebody please explain it to me.