Tell us what’s happening:
Hello Campers!
So const cannot change through re-assignment, but why here
const teaCups = [];
for(let cups = 1; cups <= numOfCups; cups += 1) {
const teaCups = prepareTea();
teaCups.push(teaCup);
}
why does const teaCups’ value change? Can someone explain it to me?
it is because the const teaCups in the loop in not related with the const outside?
and also teaCup is not defined with let or const but it exists as argument. I don’t understand this part can you help me??
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 teaCups = prepareTea();
teaCups.push(teaCup);
}
return teaCups;
};
// Add your code below this line
const tea4TeamFCC = getTea(40); // :(
// Add your code above this line
console.log(tea4TeamFCC);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
.
Link to the challenge: