title: How to make recursive function on javascript without Maximum call stack size exceeded error?
body: <p>I would like to make the same robot walk function with javascript but it get call stack size error.</p>
  
  <p><a href="http://www.chegg.com/homework-help/questions-and-answers/robot-take-steps-1-2-3-meters-write-program-allows-shows-possible-steps-robot-take-using-r-q3756383" rel="nofollow noreferrer">http://www.chegg.com/homework-help/questions-and-answers/robot-take-steps-1-2-3-meters-write-program-allows-shows-possible-steps-robot-take-using-r-q3756383</a></p>
  
  <pre><code>    function walk(meter) {
          if(meter &lt; 0) {
              count = 0;
          } else if(meter &lt;= 2) {
              count = meter;
          } else if(meter == 3) {
              count = walk(meter-1)+walk(meter-2)+1;
          } else {
              count = walk(meter-1)+walk(meter-2)+walk(meter-3);
          }
          return count;
      }
  
  
      console.log(walk(100));
  </code></pre>