Understand Functional Programming Terminology problem

Understand Functional Programming Terminology problem
0

#1

Tell us what’s happening:
Hello, I think that I am not really getting the concepts right. So the prepareTea function was added to set the type of tea(I tried adding the “type parameter”. But how exactly is the type stored, if the getTea function only return the array? In the end, the tea4FCCs only end up storing cups of tea,discriminating the type,right?

Your code so far


/**
 * A long process to prepare green tea.
 * @return {string} A cup of green tea.
 **/
const prepareGreenTea = () => 'greenTea';

/**
 * A long process to prepare black tea.
 * @return {string} A cup of black tea.
 **/
const prepareBlackTea = () => 'blackTea';

/**
 * Get given number of cups of tea.
 * @param {function():string} prepareTea The type of tea preparing function.
 * @param {number} numOfCups Number of required cups of tea.
 * @return {Array<string>} Given amount of tea cups.
 **/
const getTea = (prepareTea(type), numOfCups) => {
  const teaCups = [];

  for(let cups = 1; cups <= numOfCups; cups += 1) {
    const teaCup = prepareTea();
    teaCups.push(teaCup);
  }

  return teaCups;
};
function prepareTea(type) {
return type;
}

// Add your code below this line

const tea4GreenTeamFCC = getTea("green", 27); // :(
const tea4BlackTeamFCC = getTea("black", 13); // :(

// Add your code above this line

console.log(
  tea4GreenTeamFCC,
  tea4BlackTeamFCC
);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/understand-functional-programming-terminology


#2

The only lines of code you should be changing are the two above. Do not change the original functions like getTea. You need to assign the result of a call to the getTea function for each of these lines above. Study the getTea code and comments so you can figure out what two things you need to pass to the getTea function in order to get the desired results.


#3

Figured it out. thanks!