I have been struggling with recursion i do understand it quite a bit right now but still if anyone would love to make a simple countdown using Recursion and explain it, that would be awesome!
A count down method by recursion. The biggest problem is slowing the countdown so you can actually see the numbers change. For that we can use setInterval.
so the code below is pretty simple. First define the end case, in this case when n=0. Update the innerHTML and quit (don't return anything). ELSE return the recursive call to countdown(n-1). since we do that inside of setInterval we need to make sure we clear setinterval
var count = document.getElementById('count');
var interval;
function countDown(n){
clearInterval(interval);
if(n==0){
count.innerHTML = n
}else{
count.innerHTML=n;
interval=setInterval(function(){
return countDown(n-1);
},500);
}}
countDown(10);
<div id='count'></div>