When you open a doll, you find another doll inside, and when you open that one, there's another one inside. The act of doing this is called recursion. Let's write code for that.
function openDoll(doll) { if(doll.isEmpty()) { return doll; } openDoll(doll.open()); }
Recursion is a way of doing an operation over a set of values, where each value is related to the previous one, without iterating or using loops.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Do you know Matryoshka dolls?
When you open a doll, you find another doll inside, and when you open that one, there's another one inside. The act of doing this is called recursion. Let's write code for that.
Recursion is a way of doing an operation over a set of values, where each value is related to the previous one, without iterating or using loops.