🌐
DEV Community
dev.to › codeguppy › practice-recursion-in-javascript-with-these-8-coding-challenges-for-beginners-25bm
Practice recursion in JavaScript with these 8 coding challenges for beginners - DEV Community
November 16, 2019 - Introduction Recursion is one of the most useful but very little understood programming te... Tagged with javascript, algorithms, 100daysofcode, codenewbie.
Discussions

javascript - recursion practice : rewriting DOM methods - Stack Overflow
I am doing a practice for recursive function and trying to write DOM methods like getElementsByClassName. I understand that recursion consists of base case and recursive case but not sure how to More on stackoverflow.com
🌐 stackoverflow.com
Does anyone actually use recursion?
To all following commenters: please, do not bring up the old circlejerk jokes/memes about recursion ("Understanding recursion...", "This is recursion...", etc.). We've all heard them n+2 too many times. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/learnprogramming
63
65
May 20, 2022
[Best Practices] Recursion. Why is it generally avoided and when is it acceptable?
I know it can be frustrating, but like most design decisions there is no hard rule. Recursion should be used when it makes sense to do so, and avoided when it does not. Any experienced programmer will recognize a recursive design immediately, and have enough experience to understand/debug it. As a beginner I can only recommend that you experiment with both solutions until you get a feel for when one is better than the other. More on reddit.com
🌐 r/learnprogramming
113
112
October 31, 2012
When to use recursion?
Anything that can be done with recursion can be done with a loop. Some problems are much much easier to solve with recursion , example: most tree algorithms and graph algorithms. Recursion can easily solve a problem but can be really really bad in terms of memory use for example Fibonacci numbers. But there are things like caches you can use to improve these problems so it is a trade off sometimes. More on reddit.com
🌐 r/computerscience
80
141
May 3, 2021
🌐
Reddit
reddit.com › r/learnprogramming › having a tricky time understanding recursion in javascript
r/learnprogramming on Reddit: Having a tricky time understanding recursion in Javascript
June 9, 2022 -

I learned basic recursion the other day, but I'm still having a bit of tricky time understanding it. Like I can mostly understand how it works, but what would be a real world use for it?

Like for example in webdev. Can someone point me to a resource to explain it like I'm 5 years old?

Top answer
1 of 5
5
For webdev, the only real-world example I can give is for a CRM, we had locations in a building we needed to track, and each location could have sub-locations, and those sublocations could have sub-sub-locations. One day, we had to implement a system that if someone booked a parent location, the child locations would also be booked, and if someone booked a child location, the parent locations would become unavailable (if someone books half a gymnasium, another group obviously can't book the full gymnasium at the same time). The algorithm I ended up using was a recursive graph search. From a parent, check if any children were booked. Then move to the children and check if any of those parents were booked, then move to those children and check if any of its children were booked... Recursion is used when you encounter smaller versions of the original problem while trying to solve the original problem. That's the case when searching through a tree, where the problem at each layer is nearly identical regardless of what layer you're looking at.
2 of 5
3
Generally, you use recursion only when the recursive version of the problem is easier more intuitive to understand. Fibonacci is one of the easiest problems to understand recursion with despite the horrible inefficiency of the recursive version of that algorithm compared to just looping... A real world example I have seen in iOS programming is a case where I want to debug some views, so I want to log out information about a view and all of its subviews (and all of their subviews, etc.). So that might look something like this... func debugInfo() -> String { var debugInfo = "someInfoAboutThisView" for subview in subviews { debugInfo += "\n\(subview.debugInfo())" } } Now I'll have a debug string with information about this view and all its descendent views down the view hierarchy.
Recursion - Easily the best explanation ever! Oct 31, 2020
r/learnprogramming
5y ago
How to really understand recursion? Nov 29, 2024
r/learnprogramming
last yr.
Best way to learn recursion? Nov 7, 2023
r/learnprogramming
2y ago
More results from reddit.com
🌐
Medium
medium.com › @prabh.csulb › javascript-interview-q-a-part-2-recursion-26911c4e8a2f
Javascript Interview Q/A Part 2: Recursion | by Prabhjot Singh | Medium
October 2, 2023 - The numbers 5 to 1 are printed on the console. It is very IMPORTANT to pass the arguments in the subsequent function calls in such a way that code execution eventually comes to the BASE CONDITION and the recursive calls are stopped.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-understand-recursion-in-javascript
Recursion in JavaScript - GeeksforGeeks
Recursion is a technique where a function calls itself to solve a problem by breaking it into smaller, similar subproblems until a base condition is met.
Published   January 16, 2026
🌐
Exercism
exercism.org › tracks › javascript › concepts › recursion
Recursion in JavaScript on Exercism
Master Recursion in JavaScript by solving 6 exercises, with support from our world-class team.
🌐
CodeSignal
codesignal.com › learn › courses › sorting-and-searching-algorithms-in-js › lessons › exploring-the-magic-of-recursion-in-javascript
Exploring the Magic of Recursion in JavaScript
We dove into the sea of recursion, familiarized ourselves with vital concepts like base and recursive cases, and implemented a simple JavaScript recursive function. We'll deepen our understanding of recursion with continuous practice and be well-prepared for succeeding lessons involving complex ...
Find elsewhere
🌐
Itch
codeguppy.itch.io › books › free
8 recursion problems with JavaScript solutions by codeguppy
but instead it offers you a PDF booklet with 8 classical problems implemented both using a recursive solution as well as an iterative solution.
🌐
The Odin Project
theodinproject.com › lessons › javascript-recursive-methods
Recursive Methods | The Odin Project
Go to the computer_science/recursion/ directory of The Odin Project’s JavaScript exercises repo and complete each of the exercises in order. Be sure to review the README for each exercise prior to completing it.
🌐
LeetCode
leetcode.com › problem-list › recursion
Recursion
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
🌐
Educative
educative.io › home › courses › recursion for coding interviews in javascript
Recursion for Coding Interviews in JavaScript - AI-Powered Course
The ultimate guide to recursion interviews in JavaScript. Developed by FAANG engineers. Practice with real-world interview questions and get interview-ready in just a few hours.
🌐
Nickhuemmer
nickhuemmer.com › posts › recursion_practice_problems
JavaScript Recursion Practice Problems
February 14, 2023 - Here are some JavaScript recursion practice problems (at the bottom of the page) that I put together to train myself for the Codesmith Technical Interview.
🌐
Codewars
codewars.com › collections › recursion-1
Recursion | Codewars
Start training on this collection. Each time you skip or complete a kata you will be taken to the next kata in the series. Once you cycle through the items in the collection you will revert back to your normal training routine · Recursion problems, ...
🌐
Codesmith Enterprise
codesmith.io › blog › introduction-to-recursion-in-javascript
Codesmith | Introduction to Recursion in JavaScript
Like most things in JavaScript, there are several ways to achieve this goal. Above, the base case is slightly different: if(num <= 0) return. This is a bit safer as it accounts for the possibility of a num having a negative value. You might also notice how, instead of decrementing num and then invoking sayHi with the new value, we’ve passed num - 1 as the argument itself to the recursive sayHi call.
🌐
freeCodeCamp
freecodecamp.org › news › recursion-in-javascript-1608032c7a1f
Recursion in JavaScript
July 25, 2015 - If you’re still struggling a bit to wrap your head around recursion, the best advice I can give is to start with small examples and mentally trace the call stack. Try something like reverse(‘abc’) and walk through it, step-by-step.
🌐
Medium
medium.com › @nonyeibeanu › solutions-to-some-challenging-recursion-problems-in-javascript-485743c3c5ad
Solutions to some Challenging Recursion Problems in JavaScript | by Nonye Ibeanu | Medium
April 11, 2023 - // result is initialized to 0 by default. function nestedEvenSum(obj, result = 0) { // base case if the object is empty if(Object.keys(obj).length === 0) return result; // iterating through each key in the obj parameter for (const key in obj) { /* If the value of the current key in obj is an object, the function calls itself recursively, passing in the object as the new obj parameter.
🌐
Codecademy
codecademy.com › docs › javascript › recursion
JavaScript | Recursion | Codecademy
November 16, 2025 - This process is similar to how loops work, but recursion uses function calls instead of loop structures. In this example, the function repeatedly calls itself to print numbers from 1 to 10, stopping once the base case condition (count < 10) is no longer true: ... Front-end engineers work closely with designers to make websites beautiful, functional, and fast. ... Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
🌐
Playcode
playcode.io › javascript › recursion
JavaScript Recursion: Complete Guide with Examples | Playcode
Master JavaScript recursion: understand base cases, recursive calls, and practical examples like factorial, Fibonacci, and tree traversal. Learn when to use recursion vs iteration.