Hello, can anyone explain me something in this challenge. I understand most of it but this part bugs me
for(let cups = 1; cups <= numOfCups; cups += 1) {
const teaCup = prepareTea();
teaCups.push(teaCup);
}
How does the function prepareTea() work? It isnt declared anywhere else, and how exactly does it return green or black tea? Can anyone explain a bit more about this function call?
thanks
this is the whole code, and it runs and passes the test…
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';
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 = getTea(prepareGreenTea, 27); // :(
const tea4BlackTeamFCC = getTea(prepareBlackTea, 13); // :(
console.log(
tea4GreenTeamFCC,
tea4BlackTeamFCC
);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/understand-functional-programming-terminology