A problem about Recursive return value
						
							
function fibonacciCatch(num) {
  let cache = [1, 1];
  (function fibonacci(n) {
    if(typeof cache[n] == "number") {
      return  cache[n]
    } else {
      // return
      return cache[n] = fibonacci(n - 1) + fibonacci(n - 2)
    }
  })(num - 1);
  return cache;
}
console.log(fibonacciCatch(4))   //[ 1, 1, 2, 3 ]
 if you do not write the return in the above comments, then you will generate [1Magi 1dagan] 
. As far as I understand it, that sentence is equivalent to copying the nth item of the array. After the assignment, it can be used for operation again, so why do you need to return it? 
 recently, I have been learning algorithms for beginners. Sometimes I always feel like I can"t get around it on the recursive side. Please help me explain it in more detail. Thank you 
.
						
 
												
					 
					
						
  fibonacci (n-1) + fibonacci (n-2) to do this addition fibonacci must return a value, or else it is undefined+undefined 
 
 what the landlord should say is that there is  return  on the inner floor 
.
function fibonacciCatch(num) {
  let cache = [1, 1];
  (function fibonacci(n) {
    if(typeof cache[n] == 'number') {
      return  cache[n]
    } else {
      cache[n] = fibonacci(n - 1) + fibonacci(n - 2)
    }
  })(num - 1);
  return cache;
}
 if the function  fibonacci  does not return a value, then execute 
fibonacci(n - 1) + fibonacci(n - 2)
In this sentence, the two functions are added several times, so 
 NaN   is returned.
fibonacciCatch(6)
[1, 1, 2, NaN, NaN, NaN]
The value in the 
  cache array (starting with the third item) is the return value from the function fibonacciCatch. If you do not have the return function, the default return value is 
 
 of undefined.
 if you do not add  return , the valid code when running  FobonacciCatch (4)  is equivalent to: 
   Hello, I am headhunter David, by a very good company (more than ten billion dollars unicorn) HR specially named and commissioned to contact you, I am recruiting the head of the front-end (management front-end number of 40 +), a very good opportunity, you can send me on your phone, look forward to chatting with you on the phone thank you! My phone number is Wechat 18616723738