Tell us what’s happening:
Does my understanding about first class, higher order and lambda correct base on the comments I make on this problem?
Just making sure to understand it well, thanks for replies.
Your code so far
//This are lambda
const prepareGreenTea = () => 'greenTea';
const prepareBlackTea = () => 'blackTea';
//This one is a first class since it was declared as a variable
const getTea = (prepareTea, numOfCups) => {
const teaCups = [];
for(let cups = 1; cups <= numOfCups; cups += 1) {
const teaCup = prepareTea();
teaCups.push(teaCup);
}
return teaCups;
};
//Then this one is higher order functions as the getTea function accepts a function as an argument
const tea4GreenTeamFCC = getTea(prepareGreenTea, 27);
const tea4BlackTeamFCC = getTea(prepareBlackTea, 27);
console.log(
tea4GreenTeamFCC,
tea4BlackTeamFCC
);
Challenge: Functional Programming - Understand Functional Programming Terminology