title: Armstrong of a number javascript
body: <p>I need to know whether the entered number is an Armstrong number or not, but my code does not work for every number. Let me know what I missed. Are there any other ways?</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-js lang-js prettyprint-override"><code>var e, x, d = 0;
  var b = prompt("Enter a number");
  x=b;
  
  while (x &gt; 0) {
    e = x % 10;
    x = parseInt(x/10);
    d = d + (e*e*e);
  }
  
  if (b==d)
     alert("given number is an armstrong number");
  else
     alert("given number is not an armstrong number");</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
  &lt;head&gt;
       &lt;title&gt;Armstrong&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>