sumAll.js

This commit is contained in:
Carlos Leon, Jr 2019-10-25 17:01:54 -07:00
parent e3f8c6dcb1
commit 3e8be08b85
1 changed files with 26 additions and 1 deletions

View File

@ -1,5 +1,30 @@
const sumAll = function() {
const sumAll = function(i, n) {{
if (i < 0) {
return ('ERROR');
}
if (typeof n === 'string') {
return ('ERROR');
}
if (typeof n === 'object'){
return ('ERROR');
}
if (i > n){
([i,n] = [n,i]);
}
var myNum = 0;
for (i; i <= n; i++) {
myNum = myNum + i;
}
return (myNum);
}
sumAll(1,4);
sumAll(123,1);
sumAll(1,4000);
sumAll(-10,4);
sumAll(10,"90");
sumAll(10,[90,1]);
}
module.exports = sumAll