# Need help on: Understand Functional Programming Terminology

**URL:** <https://forum.freecodecamp.org/t/need-help-on-understand-functional-programming-terminology/310059>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [August 29, 2019, 12:05am UTC](https://forum.freecodecamp.org/t/need-help-on-understand-functional-programming-terminology/310059 "2019-08-29T00:05:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sharad823](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sharad823/32/122473_2.png) [@Sharad823](https://forum.freecodecamp.org/u/Sharad823)\
**Post date:** [August 29, 2019, 12:05am UTC](https://forum.freecodecamp.org/t/need-help-on-understand-functional-programming-terminology/310059/1 "2019-08-29T00:05:46Z")

</div>

Hello All. I’m unable to understand some basic info in this challenge.  
First, I don’t understand the comments:

/\*\*

- A long process to prepare green tea.
- @return {string} A cup of green tea.  
\*\*/

and

/\*\*

- A long process to prepare black tea.
- @return {string} A cup of black tea.  
\*\*/

What do they mean by ‘A long process to prepare green tea’ and ‘A long process to prepare black tea’ ? These don’t really seem relevant to the challenge unless I’m missing something.

Also, in the instructions they state: `Callbacks` are the functions that are slipped or passed into another function to decide the invocation of that function. What is meant by ‘to decide the invocation of that function’? Specifically, what does ‘invocation’ mean in this context? How are we deciding the invocation?

They also state, ’ Functions that can be assigned to a variable, passed into another function, or returned from another function just like any other normal value, are called `first class` functions. In JavaScript, all functions are `first class` functions.’ If all JS functions are first "class functions,’ why don’t we just call them ‘functions’ like we normally do? Why use more words to refer to the same thing?

Also, they state, ‘Note that the `getTea` function has been modified so it now takes a function as the first argument.’ How do we know that the first argument is a function?

I haven’t written any code yet since I’m still trying to figure out the explanation/instructions.

Any guidance on the above questions would be appreciated.

**Your browser information:**

User Agent is: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36`.

**Link to the challenge:**

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/functional-programming/understand-functional-programming-terminology)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![Annestezia](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/annestezia/32/74275_2.png) [@Annestezia](https://forum.freecodecamp.org/u/Annestezia)\
**Post date:** [August 30, 2019, 2:07am UTC](https://forum.freecodecamp.org/t/need-help-on-understand-functional-programming-terminology/310059/2 "2019-08-30T02:07:03Z")

</div>

Hell

```auto
/**
 * A long process to prepare green tea.
 * @return {string} A cup of green tea.
 **/

```

This is a description of the code below, just a function with some logic (=process to prepare tea, could be long, if we wrote it), which returns a string value.

```auto
const prepareGreenTea = () => 'greenTea';

```

Without arrow

```auto
const prepareGreenTea = function() {return 'greenTea';}

```

[First-class function wiki](https://en.wikipedia.org/wiki/First-class_function)  
In JavaScript, all functions are `first class` functions, in other languages may not be.

---

<div class="post-metadata">

**Author:** ![Sharad823](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sharad823/32/122473_2.png) [@Sharad823](https://forum.freecodecamp.org/u/Sharad823)\
**Post date:** [August 30, 2019, 11:22pm UTC](https://forum.freecodecamp.org/t/need-help-on-understand-functional-programming-terminology/310059/3 "2019-08-30T23:22:40Z")

</div>

Hi and thanks for your reply.

I’m still not clear about how the comments describe the code below. What do you mean by “could be long, if we wrote it?” Do you mean that the function could be long? Long in comparison to what? And it mentions “a long process” - is that referring to the function?

I’m not understanding the logic here. Why would we need to have a function? Couldn’t we just assign the variable to a string, e.g. `const prepareGreenTea = 'greenTea';`

Thanks for mentioning that functions in other languages may not be first class functions. It would have made more sense if they had explained that in the instructions, so thanks for the clarification.

Any other help would be welcome, since I still don’t have enough understanding of the instructions to address the coding challenge.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [August 31, 2019, 6:20am UTC](https://forum.freecodecamp.org/t/need-help-on-understand-functional-programming-terminology/310059/4 "2019-08-31T06:20:30Z")

</div>

it could be something like this  
it just an example of what a function could be

```auto
function prepareGreenTea () => {
   // grow plant
   // collect leaves
   // let leaves dry
   // etc
   // boil water 
   // make tea
   // now you have tea
   return greenTea;
}

```

---

<div class="post-metadata">

**Author:** ![luishendrix92](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/luishendrix92/32/95304_2.png) [@luishendrix92](https://forum.freecodecamp.org/u/luishendrix92)\
**Post date:** [August 31, 2019, 6:43am UTC](https://forum.freecodecamp.org/t/need-help-on-understand-functional-programming-terminology/310059/5 "2019-08-31T06:43:01Z")

</div>

The terminology that I’m used to is not that ‘in some languages there are first class functions’, but rather, ‘in some languages, functions are **first class objects**.’

This refers to the fact that in JavaScript (among other languages, functional ones, hybrids and even OOP like Java 8 and C# when they introduced delegates and then lambdas), functions can be treated like other objects:

- Assigned to variables:
- Returned from functions
- Passed to functions as arguments
- Stored in arrays and key-value pair objects (JSON)
- They have properties and methods too like .toString, .length, etc

This proves useful when you try to apply functional programming principles in JS such as currying, parameterization, partial application, emulated private scope and callbacks.

Now, receiving functions as arguments (let it be the first one, second one, nth one or whatever) and invoking them just means:

```auto
function executeFunctionWith5(someFunction) {
  someFunction(5)
  // or
  // someFunction.apply(this, [5])
  // or
  // someFunction.call(this, 5)
  // you just "invoked" the "callback" given as the first
  // argument (below this function declaration) and
  // specified as the first parameter here.
}

executeFunctionWith5(function(number) {
  console.log(`The double of ${number} is ${number * 2}!`)
})

//!> The dobule of 5 is 10!

```

---

<div class="post-metadata">

**Author:** ![Sharad823](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sharad823/32/122473_2.png) [@Sharad823](https://forum.freecodecamp.org/u/Sharad823)\
**Post date:** [August 31, 2019, 1:33pm UTC](https://forum.freecodecamp.org/t/need-help-on-understand-functional-programming-terminology/310059/6 "2019-08-31T13:33:14Z")

</div>

Thanks for the reply.

After reviewing and understanding (I think!) the solution code, I don’t think the comments accurately describe the code. It’s confusing for someone reading the code, since there is no ‘long process’ in the code.

I think it would have made more sense to comment:

```auto
/**
 * @return {string} 'greenTea' which represents one cup of green tea. 
 **/

```

I’m still not clear on why we cannot just use:

`const prepareTea = 'greenTea';`

Is there any reason we need to make it into a function, rather than just assigning the variable to the string ‘greenTea?’

---

<div class="post-metadata">

**Author:** ![Sharad823](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sharad823/32/122473_2.png) [@Sharad823](https://forum.freecodecamp.org/u/Sharad823)\
**Post date:** [August 31, 2019, 1:36pm UTC](https://forum.freecodecamp.org/t/need-help-on-understand-functional-programming-terminology/310059/7 "2019-08-31T13:36:20Z")

</div>

Thanks for taking the time to provide this detailed explanation.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 25, 2021, 12:17pm UTC](https://forum.freecodecamp.org/t/need-help-on-understand-functional-programming-terminology/310059/8 "2021-01-25T12:17:25Z")

</div>

Closed on January 25, 2021, 12:17pm UTC


