JavaScript: How to reverse a number?
<p>Below is my source code to reverse (as in a mirror) the given number.
I need to reverse the number using the reverse method of arrays.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script&gt;
   
    var a = prompt("Enter a value");
    var b, sum = 0;
    var z = a;
    while(a &gt; 0)
    {
      b = a % 10;
      sum = sum * 10 + b;
      a = parseInt(a / 10);
    }
    alert(sum);
&lt;/script&gt;</code></pre>
</div>
</div>
</p>