Recursion!... But Make It Simplified

Recursion — TheBurningMonk.com

What is Recursion?

Russian Stacking Doll Gif — Tenor

Wouldn’t A Recursive Code Lead To An Infinite Loop?

function countDown(n){console.log(n)if(n > 1){countDown(n -1) // recursive call} else {return true // base case}}countDown(5)// 5// 4// 3// 2// 1countDown(-1)
// - 1
// true
countDown(5)
countDown(4)
countDown(3)
countDown(2)
countDown(1)
return
return
return
return
return

So What Are the Pros and Cons of Writing Recursive code?

What is this “Stack ” you mentioned?

leggo stacking

So, Should I Use Recursion Instead Of Iteration?

Software Engineer