I need to clear an interval from another function
window.onload = function(){
    var interval = null;
    interval = setInterval(function(){
        myFunction();
    }, 1000);
    function stop(){
        clearInterval(interval);
    }
}
without pass the interval variable
stop();
But I cannot make it working: when I call stop(); the interval continues...
How can I do?

 
    
 
     
     
    