My code doesn't work:: Learn About Functional Programming

Tell us what’s happening:

They ask me to call the getTea function
which i did
then asked to add 40 tea cups to it which i did
and then store it in the tea4TeamFCC which i once again did
but test doesn’t pass why not?
what did i miss here

Your code so far

// Function that returns a string representing a cup of green tea
const prepareTea = () => 'greenTea';

Given a function (representing the tea type) and number of cups needed, the
following function returns an array of strings (each representing a cup of
a specific type of tea).
const getTea = (numOfCups) => {
 const teaCups = [];

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

// Only change code below this line
prepareTea  = getTea(40) ;
const tea4TeamFCC = null;
// Only change code above this line

Your browser information:

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

Challenge: Learn About Functional Programming

Link to the challenge:

Well, you are assigning the returned tea array to prepareTea, which was previously a function to create “greenTea” string.

Then tea4TeamFCC still holds the value null, while the exercise expect it to holds 40 tea.

Hope this helps :slight_smile:

1 Like

So the 40 value get’s overwritten by the null value.
and i should assign the const to the getTea one since
prepareTea is a function to create the string
I think i get i thank u :3

1 Like