Hey, I'm Saber (not a sword tho :") Basically a web developer. currently I'm enrolled in academic ComputerScience degree,
I also Passed the 10,000 hours rule !!
finally C++ Sucks just admit it .
Given this is the definition of cookiesBaker function
letcookiesBaker=function(cook){returnfunction(secretIngredient){returnfunction(chocolate){return`${cook} cooked a ${secretIngredient}${chocolate} chocolate cookie.`}}
As you can see here, there's 3 functions, one with two nested functions. each one of em takes a parameter. so we need to call the function with three different nested parameters in order to meet its requirement.
like so cookiesBaker("Sarah")("peanut butter")("white") which will return a value of "Sarah cooked a peanut butter white chocolate cookie."
How it worked? cookiesBaker("Sarah") calling this alone will evaluate and set parameter "cook" equal to "Sarah" then returns a function. in which that function will be called as following cookiesBaker("Sarah")returnedFunction("peanut butter") which will evaluate parameter "secretgradient" to "peanut butter" then returns a function that will be called as cookiesBaker("Sarah")returnedFunction("peanut butter")returnedFunctionTwo("white") which will evaluate parameter "chocolate" to "white" then returns a string value equal to "Sarah cooked a peanut butter white chocolate cookie."
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Given this is the definition of cookiesBaker function
As you can see here, there's 3 functions, one with two nested functions. each one of em takes a parameter. so we need to call the function with three different nested parameters in order to meet its requirement.
like so
cookiesBaker("Sarah")("peanut butter")("white")
which will return a value of "Sarah cooked a peanut butter white chocolate cookie."How it worked?
cookiesBaker("Sarah")
calling this alone will evaluate and set parameter "cook" equal to "Sarah" then returns a function. in which that function will be called as followingcookiesBaker("Sarah")returnedFunction("peanut butter")
which will evaluate parameter "secretgradient" to "peanut butter" then returns a function that will be called ascookiesBaker("Sarah")returnedFunction("peanut butter")returnedFunctionTwo("white")
which will evaluate parameter "chocolate" to "white" then returns a string value equal to "Sarah cooked a peanut butter white chocolate cookie."