Created
January 22, 2019 16:16
-
-
Save cristianbgp/bb916df62a4f41c08a8e746d85ae5dc0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Get the sum of all the numbers between a and b | |
function GetSum( a,b ) | |
{ | |
sum = 0; | |
if(a<b){ | |
for (let i = a; i <= b; i++) { | |
sum += i; | |
} | |
}else if(b<a){ | |
for (let i = b; i <= a; i++) { | |
sum += i; | |
} | |
}else{ | |
return a; | |
} | |
return sum; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment