daily pastebin goal
25%
SHARE
TWEET

Untitled

a guest Jan 13th, 2018 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.   <meta charset="utf-8">
  5.   <meta name="viewport" content="width=device-width">
  6.   <title>JS Bin</title>
  7. </head>
  8. <body>
  9.  
  10. <script id="jsbin-javascript">
  11. function addSum( numbers) {
  12. /*  var sum = 0;
  13.   var count = 0;
  14.   var max = 0;
  15.   if( numbers[0] > numbers[1]){
  16.     count = numbers[1];
  17.     max = numbers[0];
  18.   } else {
  19.     count = numbers[0];
  20.     max = numbers[1];
  21.   }
  22. */
  23.   var sum = 0;
  24.   var sorted = numbers.sort();
  25.  
  26.   for(i = sorted[0]; i <= sorted[1]; i++)
  27.     {
  28.       sum = sum + i;
  29.     }
  30.   return sum;
  31. }
  32.  
  33. console.log(addSum([1,5]));
  34.  
  35.  
  36. //1,5, pick the greater
  37. </script>
  38.  
  39.  
  40.  
  41. <script id="jsbin-source-javascript" type="text/javascript">function addSum( numbers) {
  42. /*  var sum = 0;
  43.   var count = 0;
  44.   var max = 0;
  45.   if( numbers[0] > numbers[1]){
  46.     count = numbers[1];
  47.     max = numbers[0];
  48.   } else {
  49.     count = numbers[0];
  50.     max = numbers[1];
  51.   }
  52. */
  53.   var sum = 0;
  54.   var sorted = numbers.sort();
  55.  
  56.   for(i = sorted[0]; i <= sorted[1]; i++)
  57.     {
  58.       sum = sum + i;
  59.     }
  60.   return sum;
  61. }
  62.  
  63. console.log(addSum([1,5]));
  64.  
  65.  
  66. //1,5, pick the greater</script></body>
  67. </html>
RAW Paste Data
Top