why recursion is returning undefined in javascript? : <p>I'm using recursion to reverse the number. in the terminating condition i am returning the result. but it's returning "undefined". the console inside the if is showing the correct output.    </p>

<p>// reverse the number</p>

<pre><code>var result= "";
var reverse = function(x) {

if(x == 0){
    console.log("result",result);
    return result;
}else{
    var lastDigit = x % 10; 
  result += lastDigit;
  x = Math.floor(x/10);
  reverse(x);
}
};

console.log(reverse(73254));
</code></pre>
