Advertisement
andrewb

powers.html

Jun 26th, 2015
600
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <title>FuncFunc</title>
  5.     <script>
  6.  
  7. var newLine = function(str) {
  8.     var content = document.getElementById("content");
  9.     content.innerHTML = content.innerHTML + str + "<br/>";
  10. };
  11.  
  12. var powers = function(p) {
  13.     var power = p;
  14.    
  15.     return function(num) {
  16.         var ans = num;
  17.         for (var c = 0; c < (power-1); c++) {
  18.             ans = ans * num;
  19.         }
  20.         return ans;
  21.     };
  22. };
  23.  
  24. var square = powers(2);
  25. var cube = powers(3);
  26.  
  27.     </script>
  28. </head>
  29. <body>
  30.     <div id="content"></div>
  31.     <script>
  32. newLine(square(2));
  33. newLine(square(3));
  34. newLine(square(4));
  35. newLine(cube(5));
  36.     </script>
  37. </body>
  38. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement