title: How to save the return value of a recursive function in a variable JavaScript
body: <p>I need to store the return value in a variable.</p>
  
  <p>I want to know how to fix this code. I know that if the value of b would be 3, I would get value=2, but if the function does more than one iteration I get unidentified. I read that I should use the callback or something but I don't know how, also an explanation of why my code doesn't work and how should I fix it. (Of course this code is for demonstration purpose as if I would show you the original it might get confusing.) Thanks a lot! </p>
  
  <pre><code>var b = 70;
  
  function myfunction() {
      b--;
      if (b &lt; 3) {
          return b;
      } else {
          myfunction();
      }
  }
  value = myfunction();
  console.log(value);
  </code></pre>