Tell us what’s happening:
help me understand this
Your code so far
/**
* A long process to prepare green tea.
* @return {string} A cup of green tea.
**/
const prepareGreenTea = () => 'greenTea';
const tea4GreenTeamFCC = 27 * prepareGreenTea();
/**
* 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, 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 tea4GreenTeamFCC = null; // :(
const tea4BlackTeamFCC = null; // :(
// 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.79 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/understand-functional-programming-terminology
You messed up all your code. You need to update the code where FCC asked you to.
Note: The following line numbers are imaginary and only represent to its actual code and not the @params.
Lines 1 will help you to make a 'Green Tea'
Lines 2 will help you to make a 'Black Tea'
const prepareGreenTea = () => 'greenTea';
const prepareBlackTea = () => 'blackTea';
Line 3 This function is just like a Tea-Creating-Machine it's up to you,
to make a green tea or a black tea and no of cups.
const getTea = (prepareTea, numOfCups) => {
const teaCups = [];
for(let cups = 1; cups <= numOfCups; cups += 1) {
const teaCup = prepareTea();
teaCups.push(teaCup);
}
return teaCups;
};
Line 4: This is where you actually need to write you code.
// Add your code below this line
const tea4GreenTeamFCC = null; // Prepare 27 cups of green tea
const tea4BlackTeamFCC = null; // 13 cups of black tea
// Add your code above this line
Line 5: Your results will output to console.
console.log(
tea4GreenTeamFCC,
tea4BlackTeamFCC
);
Functional Programming is a paradigm, writing all or most of your code using Pure functions.
Read More: https://www.quora.com/What-is-functional-programming
I think the essence of this challenge is to show you how to call a function within a function.
You’ve got three functions there, one prepare green tea and another black tea. The last function gets the tea you prepared, and needed two parameters of which one needs to be a function and the other a number.
1 Like
you have to understand how to use( callback functions or higher order functions ) to pass this challenge .
2 Likes