sumAll Solution

This commit is contained in:
Karem Quiroz 2020-07-01 19:43:35 -05:00 committed by GitHub
parent 888383a44e
commit 5481761795
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -1,4 +1,17 @@
const sumAll = function() {
const sumAll = function(nmin,nmax) {
if(nmin < 0 || nmax < 0) return 'ERROR';
if(typeOf nmin!== "number" || typeOf nmax!== "number") return 'ERROR';
if(nmin > nmax){
const tem = nmin;
nmin = nmax;
nmax = tem;
}
let sum = 0;
for( let i = nmin ; i <= nmax ; i++){
sum+= i
}
return sum;
}