
fadi_fadi
asked on
Sum of arg1 and arg2 in JavaScript.
Dear Experts,
Example:
f=makeadder(3)
f(2) /* return 5 */
f(10) /* return 13 */
g=makeadder(-1)
g(2) /* return 1 */
g(10) /* return 9 */
makeadder(5)(6) /* return 11 */
Can you help me to create a function take single input argument and return new function of one argument?
This new function should return the sum of arg1 and arg2 when called.
Example:
f=makeadder(3)
f(2) /* return 5 */
f(10) /* return 13 */
g=makeadder(-1)
g(2) /* return 1 */
g(10) /* return 9 */
makeadder(5)(6) /* return 11 */
Can you help me to create a function take single input argument and return new function of one argument?
This new function should return the sum of arg1 and arg2 when called.
ASKER CERTIFIED SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.

ASKER
Your are the best.
function makeadder( arg1, arg2 )
{
return function (arg2)
{
return (arg1 + arg2);
}
}