Guest User

Untitled

a guest
Feb 21st, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. function sumAll(arr) {
  2. if (arr[0] == arr[1]) {
  3. return arr[0];
  4. }
  5.  
  6. if (arr[0] < arr[1]) {
  7. for (var i = arr[0]; i < arr[1]; i++) {
  8. arr[0] += (i + 1);
  9. }
  10. return arr[0];
  11. }
  12.  
  13. if (arr[1] < arr[0]) {
  14. for (var j = arr[1]; j < arr[0]; j++) {
  15. arr[1] += (j + 1);
  16. }
  17. return arr[1];
  18. }
  19. sumAll([1, 4]);
  20. }
  21.  
  22. // Ugly, but functional.
Add Comment
Please, Sign In to add comment