Ad
  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar
  • Default User Avatar

    Here is the explain to everyone about the
    function plus(n) { return function (a) { return a + n } }

    Let's say we need to do something like two(plus(three()))

    I.The javascript is running from the inside 1st right?

    then it will try to calculate three() meaning 3 , there is nothing hard here

    II.now to the plus(three())

    plus(three()) == plus(3)
    

    if u trying to console.log(plus(three())), u will see it return

    return function (a) { return a + n }
    

    and nothing is calculated.
    or i can say

    two(plus(three))        ==        two(return function (a) { return a + 3 })
    

    III. Remember two(something_in_here) function? it

    return something_in_here(2)
    

    or i can say

    two(plus(three))    ==    return f(2)
    

    To summarize all from 1-> 3, we have everything explained below

      two(plus(three))    ==    two(return function (a) { return a + n })
      return f(2)         ==    return function (a) { return a + 3 }) //we remove the sames of 2 sides of this equation
      f(2)                ==    function (a) { return a + 3 })
    

    ==> this mean 2 has been assigned to a!

    So that' how.

  • Default User Avatar

    let me show u why:
    "This-i mean all of this-will be my string" => "hisTay-iay eanmay llaay foay histay-illway ebay ymay tringsay"