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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Your are the best.
function makeadder( arg1, arg2 )
{
return function (arg2)
{
return (arg1 + arg2);
}
}