Toast is in Beta!Big news! Toast is in Beta!Learn more →

Say we have the following function:

<code class="javascript">function increaseBy(x){return function(y){return x + y;}}

We can use this function to create new, higher order functions that increase a number by a certain value.

for example:

<code class="javascript">var incByThree = increaseBy(3);

gives us a function we can then use later in our code as such:

<code class="javascript">incByThree(4);//returns 7incByThree(5);//returns 8

We can also create multiple higher-order functions and have each of them use a different x value;

<code class="javascript">var incByThree = increaseBy(3);var incByFour = increaseBy(4);incByThree(6);//returns 9incbyFour(6);//returns 10