Avatar of fadi_fadi
fadi_fadi
 asked on

Creating a function in javascript

I'm trying to create a function "makeadder(arg1)" that takes a single input argument and return a new function f(arg2) of one argument.
 This new function should return the sum of arg1 and arg2 when called.

As a Examples:

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 */
Scripting Languages

Avatar of undefined
Last Comment
fadi_fadi

8/22/2022 - Mon
Michel Plungjan

fadi_fadi

ASKER
I read it, but it's very complicated for me.
can you provide me with simple example
ASKER CERTIFIED SOLUTION
Gurvinder Pal Singh

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
fadi_fadi

ASKER
Can you advice me, which is the best source(Books, sites..........etc) to learn Javascript.
Because your giving me, exactly what i want.

Thanks
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Michel Plungjan

fadi_fadi

ASKER
You are the best.
Thanks for your advice