Learn About Functional Programming

Tell us what’s happening:

The tea4TeamFCC variable should hold 40 cups of tea for the team.
The tea4TeamFCC variable should hold cups of green tea.

Your code so far


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

/**
 * Get given number of cups of tea.
 * @param {number} numOfCups Number of required cups of tea.
 * @return {Array<string>} Given amount of tea cups.
 **/
const getTea = (numOfCups) => {
  const teaCups = [];
  
  for(let cups = 1; cups <= numOfCups; cups += 1) {
    const teaCup = prepareTea();
    teaCups.push(teaCup);
  }

  return teaCups;
};

// Add your code below this line

const tea4TeamFCC = 40; // :(

// Add your code above this line

console.log(tea4TeamFCC);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0.

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

@caseydev The tests are looking for an array of 40 'greenTea' strings, not 40 as an integer. Can you figure it out from there?

If you’re still lost, solution:

const tea4TeamFCC = getTea(40);

1 Like