function add(x) {_______}; alert(add(2)(3)(4)); //Fill in the blanks so that the result is 9
Solution 1,
//貘大
function add(x) {
var c = 0;
return function(x) {
c = c x ; arguments.callee.toString = function(){
return c;
};
return arguments.callee;
}(x);
};
alert(add(2)(3)(4));
Solution 2,
//Sangui
function add(x) {
return function(y){
return function(z ){
return x y z;
}
}
};
alert(add(2)(3)(4));
Solution 3,
//Situ Zhengmei
function add (a) {
if(!isFinite(add.i)){
add.i = a
}else {
add.i = a;
}
add.valueOf = add .toString = function(){
return add.i
}
return add;
}
alert(add(2)(3)(4))
Actually, the above question is a curry test. Please see my other blog post for details.
If you have a different solution, please give me some advice!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn