Advertisement
Guest User

Refactored

a guest
Jan 7th, 2014
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.55 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3.     <head lang="en">
  4.             <meta charset="utf=8">
  5.             <title>Exercise</title>
  6.     </head>
  7.     <body>
  8.         <h1>Exercise</h1>
  9.         <h3 id="message"></h3>
  10.  
  11.         <script>
  12.             var result = 1;
  13.             var numInput = Number(prompt("Factorial calculation: please enter a number"));
  14.  
  15.             for (i = 2; i <= numInput; i++) {
  16.             result = result * i;
  17.             }
  18.  
  19.             var htmlRef = document.getElementById("message");
  20.             htmlRef.textContent = numInput + "! = " + result;
  21.        </script>
  22.     </body>
  23. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement