Recursive function in JavaScript

<SCRIPT>
   function fib (inNum) {
      if (inNum == 0) 
        var fibNum = 0;
      else{
        if (inNum == 1)
           fibNum = 1;
        else{
           fibNum = fib(inNum - 2) + fib(inNum - 1);
        }
     }
     return fibNum;
   }

   function writeFibs(topFib) {
      for (var i=0;  i <= topFib ; i++) {
        document.write ("Fib(" + i + ") = " + fib(i) + " <br>");
      }
   }
   
   </SCRIPT>