-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2020-03-12 实现add方法 #7
Comments
function add(v) {
if(v === undefined) return 0;
let sum = v;
return function(val){
if(val === undefined) return sum;
return add(val + sum);
}
} |
const add = (n, S = n) => typeof n !== 'undefined' ? m => add(m, isNaN(m) ? S :S+m) : S; |
function add(args){ |
|
function add(num) {
let sum;
if(arguments.length === 0) {
sum=0;
return sum;
}
else{
sum = num;
return function innerAdd(number) {
if(arguments.length === 0){
return sum;
}
else{
return add(number + sum);
}
}
}
} |
function add(number){
if (number!== 0 && !number) return 0
return function (num) {
if (num) return add(number + num)
return number
}
} |
function add(number = 0){
return function add2(num) {
number += num || 0
if (num===undefined) return number
return add2
}
} |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
实现 该 add 方法
The text was updated successfully, but these errors were encountered: