Skip to content

Instantly share code, notes, and snippets.

@cristianbgp
Created January 22, 2019 16:16
Show Gist options
  • Save cristianbgp/bb916df62a4f41c08a8e746d85ae5dc0 to your computer and use it in GitHub Desktop.
Save cristianbgp/bb916df62a4f41c08a8e746d85ae5dc0 to your computer and use it in GitHub Desktop.
//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