For the following js code:
let myAnimation;
setTimeout(function(){myAnimation = requestAnimationFrame(turn);}, 500);
Because of scope, the following code does not work to stop the animation:
btnStop.addEventListener('click', function(){cancelAnimationFrame(myAnimation);});
Any suggestion?