# Today What I Learned

Javascript를 배우고 있습니다. 매일 배운 것을 이해한만큼 정리해봅니다.

**[Key Concepts When Coding Recursion Function]**

- Break the problem I am trying to solve down into a problem that is
**one step simpler**
*Assume* that my function will work to solve the simpler problem — really **believe** it beyond any doubt
- Ask myself: Since I
*know* I can solve the simpler problem, how would I solve the more complex problem?

**My Practices**

### 1. Example 1) a recursive function that reverses a string

- What is the One step simpler problem: I have to reverse the string from index 1 to index last.
- What is the Base case? if the given string is one character or less, then you don't need to reverse it but instead you show the string itself. The other part belongs to the recursive case.
- Let's believe the one step simpler problem will be resolved by my code somehow.

### 2. Example 2) a recursive function that prints all elements in an array

- What is the One step simpler problem: I have to print the rest of elements in the given array except the first one.

- What is the Base case? if the given array is one character or less and it's not an array, then you can just show the first index of it. The other part belongs to the recursive case.

- Now only the complex problem is left, let's focus on solving it.

- What is the Base case? if the given string is one or two characters, then it's true. The other part belongs to the recursive case.

- Now only the complex problem is left, let's focus on solving it. In this case, it's divided into two cases(odd number, even number).

- What is the Base case? if the given array is empty, it returns an empty array itself.

- Now only the complex problem is left, let's focus on solving it.